Re: Volume Indicators for MT4

541
alpha24 wrote: Mon Oct 03, 2022 4:11 am Dear Mrtools Sir,

please make this volume or any volume indicator for "any symbol" usable indicator.

download/file.php?id=3439534
Volume On-Chart indicator

Added multi symbol capability.
These users thanked the author mrtools for the post (total 5):
Chickenspicy, alpha24, ParallelNative, Milad8732, pipsquirrel


DownloadRe: Volume Indicators for MT4

542
Hi Mr.Tools,
Can you please implement the band for TSV indicator as shown in the attachment?

Here the logic:

Code: Select all

//@version=4
// 
// Time Segmented Volume Bands by @samgozman (https://github.com/samgozman)
// 
// How to use this script: https://github.com/samgozman/time-segmented-volume-bands-tradingview
// 
// ++++++++++ Warning: The script is provided for educational purposes only. ++++++++++ //
study("Time Segmented Volume Bands", shorttitle="TSV Bands")

// ++++++++++ INPUTS ++++++++++ //
tsv_length = input(13, title="TSV length", minval=1, group="Classic TSV settings")
ma_fast_length = input(7, title="MA length", minval=1, group="Classic TSV settings")
tsv_bands_length = input(44, title="TSV Bands length", minval=1, group="Bands")
tsv_bands_excess_high= input(180, title="TSV exceeds higher band, %", minval=0, group="Bands")
tsv_bands_excess_low = input(100, title="TSV exceeds lower band, %", minval=0, group="Bands")
tsv_loopback = input(60, title="TSV loopback period", minval=1, group="Table")
table_size = input(title="Table size", defval="normal", options=["none","tiny", "normal"], group="Table")

// ++++++++++ SETTINGS - Color ++++++++++ //
green = color.new(color.green, 30)
red = color.new(color.red, 30)
green_soft = color.new(color.green, 90)
red_soft = color.new(color.red, 90)

// ++++++++++ LOGIC - Helper functions ++++++++++ //
// Return stringified volume 
volstring(value) => value > 0 ? tostring(value, format.volume) : "-" + tostring(-1*value, format.volume)
// Return color based on difference
colorify(a, b) => a > b ? color.green : a < b ? color.red : color.yellow
// Create % string (50%)
percentstring(p) => " (" + tostring(p, format.percent) + ")"
// Bullish / bearish text
bullbear_text(value) => value > 0 ? "Bullish" : value < 0 ? "Bearish" : "Neutral"// Bullish / bearish color
bullbear_color(value) => value > 0 ? color.green : value < 0 ? color.red : color.yellow

// ++++++++++ LOGIC - TSV ++++++++++ //
tsv = sum(close > close[1] or close < close[1] ? volume * (close - close[1]) : 0, tsv_length)
ma = sma(tsv, ma_fast_length)

// ++++++++++ LOGIC - Inflow / outflow for table ++++++++++ //
inflow = sum(tsv > 0 ? tsv : 0, tsv_loopback)
outflow = sum(tsv < 0 ? tsv : 0, tsv_loopback) * -1
difference = inflow - outflow
total = inflow + outflow
inflow_p = inflow / total * 100
outflow_p = outflow / total * 100

// ++++++++++ LOGIC - AVG bands ++++++++++ //
avg_inflow = sma(tsv > 0 ? tsv : na, tsv_bands_length)
avg_outflow = sma(tsv < 0 ? tsv : na, tsv_bands_length)

// ++++++++++ PLOT - Main lines ++++++++++ //
plot(tsv, color=tsv > 0 ? green : red, style=plot.style_histogram, title="TSV", linewidth=2)
plot(ma, color=color.yellow, title="MA", linewidth=2)

// ++++++++++ PLOT - AVG bands ++++++++++ //
plot(avg_inflow, color=color.blue, title="avg_inflow", linewidth=1)
plot(avg_outflow, color=color.blue, title="avg_outflow", linewidth=1)

// ++++++++++ PLOT - H-Line ++++++++++ //
hline(0, title='Zero line', color=color.white, linestyle=hline.style_dotted, linewidth=1)
// ++++++++++ PLOT - Marks ++++++++++ //
plotshape(tsv > (avg_inflow * (tsv_bands_excess_high / 100 + 1)), title="Sell", color = color.red, style=shape.xcross, location=location.top, size=size.tiny)
plotshape(tsv < (avg_outflow * (tsv_bands_excess_low / 100 + 1)), title="Buy", color = color.green, style=shape.xcross, location=location.bottom, size=size.tiny)

// ++++++++++ PLOT - Background signal ++++++++++ //
bgcolor(crossover(tsv, 0) ? green_soft : na)
bgcolor(crossunder(tsv, 0) ? red_soft : na)

// ++++++++++ PLOT - Table  ++++++++++ //
size = table_size == "normal" ? size.small : table_size == "tiny" ? size.tiny : size.auto
var tbl = table.new(position.top_right, 2, 6)
if(table_size != "none")
    table.cell(tbl, 0, 0, "Inflow for " + tostring(tsv_loopback) + " periods",  bgcolor = #bbbbbb, text_size = size)
    table.cell(tbl, 1, 0, "Outflow for " + tostring(tsv_loopback) + " periods", bgcolor = #bbbbbb, text_size = size)
    table.cell(tbl, 0, 1, volstring(inflow) + percentstring(inflow_p),  bgcolor = color.white, text_size = size)
    table.cell(tbl, 1, 1, volstring(outflow) + percentstring(outflow_p), bgcolor = color.white, text_size = size)
    table.cell(tbl, 0, 2,  tostring(tsv_loopback) + " period vol difference:",  bgcolor = #bbbbbb, text_size = size)
    table.cell(tbl, 1, 2, volstring(difference), bgcolor = colorify(inflow, outflow), text_size = size)
    table.cell(tbl, 0, 3, tostring(tsv_loopback) + " period vol sentiment:",  bgcolor = #bbbbbb, text_size = size)
    table.cell(tbl, 1, 3, bullbear_text(difference),  bgcolor = bullbear_color(difference), text_size = size)
    table.cell(tbl, 0, 4, "Last volume sentiment:",  bgcolor = #bbbbbb,  text_size = size)
    table.cell(tbl, 1, 4, bullbear_text(tsv),  bgcolor = bullbear_color(tsv), text_size = size)
    table.cell(tbl, 0, 5, "Last MA sentiment:",  bgcolor = #bbbbbb,  text_size = size)
    table.cell(tbl, 1, 5, bullbear_text(ma),  bgcolor = bullbear_color(ma), text_size = size)
I would like to have the option to select the moving average and period for the band.

I have tried to implement but I couldn't do it. If you could help, it will be really great. Thanks.
These users thanked the author Vinodh for the post (total 2):
Milad8732, Chickenspicy

Re: Volume Indicators for MT4

543
kvak wrote: Tue May 24, 2022 7:51 am Buffer 8,9- - - UP,DOWN arrows...
This is a very promising volume indicator.
Please add a button and with auto adjust histo bars.
Thanks in advance
We create order out of chaos - we trade that order, but sometimes that chaos is out of order, so we WAIT!!! for the order to return - and we trade again. XARD777

Re: Volume Indicators for MT4

545
Vinodh wrote: Thu Oct 13, 2022 4:50 pm Hi Mr.Tools,
Can you please implement the band for TSV indicator as shown in the attachment?

Here the logic:

Code: Select all

//@version=4
// 
// Time Segmented Volume Bands by @samgozman (https://github.com/samgozman)
// 
// How to use this script: https://github.com/samgozman/time-segmented-volume-bands-tradingview
// 
// ++++++++++ Warning: The script is provided for educational purposes only. ++++++++++ //
study("Time Segmented Volume Bands", shorttitle="TSV Bands")

// ++++++++++ INPUTS ++++++++++ //
tsv_length = input(13, title="TSV length", minval=1, group="Classic TSV settings")
ma_fast_length = input(7, title="MA length", minval=1, group="Classic TSV settings")
tsv_bands_length = input(44, title="TSV Bands length", minval=1, group="Bands")
tsv_bands_excess_high= input(180, title="TSV exceeds higher band, %", minval=0, group="Bands")
tsv_bands_excess_low = input(100, title="TSV exceeds lower band, %", minval=0, group="Bands")
tsv_loopback = input(60, title="TSV loopback period", minval=1, group="Table")
table_size = input(title="Table size", defval="normal", options=["none","tiny", "normal"], group="Table")

// ++++++++++ SETTINGS - Color ++++++++++ //
green = color.new(color.green, 30)
red = color.new(color.red, 30)
green_soft = color.new(color.green, 90)
red_soft = color.new(color.red, 90)

// ++++++++++ LOGIC - Helper functions ++++++++++ //
// Return stringified volume 
volstring(value) => value > 0 ? tostring(value, format.volume) : "-" + tostring(-1*value, format.volume)
// Return color based on difference
colorify(a, b) => a > b ? color.green : a < b ? color.red : color.yellow
// Create % string (50%)
percentstring(p) => " (" + tostring(p, format.percent) + ")"
// Bullish / bearish text
bullbear_text(value) => value > 0 ? "Bullish" : value < 0 ? "Bearish" : "Neutral"// Bullish / bearish color
bullbear_color(value) => value > 0 ? color.green : value < 0 ? color.red : color.yellow

// ++++++++++ LOGIC - TSV ++++++++++ //
tsv = sum(close > close[1] or close < close[1] ? volume * (close - close[1]) : 0, tsv_length)
ma = sma(tsv, ma_fast_length)

// ++++++++++ LOGIC - Inflow / outflow for table ++++++++++ //
inflow = sum(tsv > 0 ? tsv : 0, tsv_loopback)
outflow = sum(tsv < 0 ? tsv : 0, tsv_loopback) * -1
difference = inflow - outflow
total = inflow + outflow
inflow_p = inflow / total * 100
outflow_p = outflow / total * 100

// ++++++++++ LOGIC - AVG bands ++++++++++ //
avg_inflow = sma(tsv > 0 ? tsv : na, tsv_bands_length)
avg_outflow = sma(tsv < 0 ? tsv : na, tsv_bands_length)

// ++++++++++ PLOT - Main lines ++++++++++ //
plot(tsv, color=tsv > 0 ? green : red, style=plot.style_histogram, title="TSV", linewidth=2)
plot(ma, color=color.yellow, title="MA", linewidth=2)

// ++++++++++ PLOT - AVG bands ++++++++++ //
plot(avg_inflow, color=color.blue, title="avg_inflow", linewidth=1)
plot(avg_outflow, color=color.blue, title="avg_outflow", linewidth=1)

// ++++++++++ PLOT - H-Line ++++++++++ //
hline(0, title='Zero line', color=color.white, linestyle=hline.style_dotted, linewidth=1)
// ++++++++++ PLOT - Marks ++++++++++ //
plotshape(tsv > (avg_inflow * (tsv_bands_excess_high / 100 + 1)), title="Sell", color = color.red, style=shape.xcross, location=location.top, size=size.tiny)
plotshape(tsv < (avg_outflow * (tsv_bands_excess_low / 100 + 1)), title="Buy", color = color.green, style=shape.xcross, location=location.bottom, size=size.tiny)

// ++++++++++ PLOT - Background signal ++++++++++ //
bgcolor(crossover(tsv, 0) ? green_soft : na)
bgcolor(crossunder(tsv, 0) ? red_soft : na)

// ++++++++++ PLOT - Table  ++++++++++ //
size = table_size == "normal" ? size.small : table_size == "tiny" ? size.tiny : size.auto
var tbl = table.new(position.top_right, 2, 6)
if(table_size != "none")
    table.cell(tbl, 0, 0, "Inflow for " + tostring(tsv_loopback) + " periods",  bgcolor = #bbbbbb, text_size = size)
    table.cell(tbl, 1, 0, "Outflow for " + tostring(tsv_loopback) + " periods", bgcolor = #bbbbbb, text_size = size)
    table.cell(tbl, 0, 1, volstring(inflow) + percentstring(inflow_p),  bgcolor = color.white, text_size = size)
    table.cell(tbl, 1, 1, volstring(outflow) + percentstring(outflow_p), bgcolor = color.white, text_size = size)
    table.cell(tbl, 0, 2,  tostring(tsv_loopback) + " period vol difference:",  bgcolor = #bbbbbb, text_size = size)
    table.cell(tbl, 1, 2, volstring(difference), bgcolor = colorify(inflow, outflow), text_size = size)
    table.cell(tbl, 0, 3, tostring(tsv_loopback) + " period vol sentiment:",  bgcolor = #bbbbbb, text_size = size)
    table.cell(tbl, 1, 3, bullbear_text(difference),  bgcolor = bullbear_color(difference), text_size = size)
    table.cell(tbl, 0, 4, "Last volume sentiment:",  bgcolor = #bbbbbb,  text_size = size)
    table.cell(tbl, 1, 4, bullbear_text(tsv),  bgcolor = bullbear_color(tsv), text_size = size)
    table.cell(tbl, 0, 5, "Last MA sentiment:",  bgcolor = #bbbbbb,  text_size = size)
    table.cell(tbl, 1, 5, bullbear_text(ma),  bgcolor = bullbear_color(ma), text_size = size)
I would like to have the option to select the moving average and period for the band.

I have tried to implement but I couldn't do it. If you could help, it will be really great. Thanks.
Hi Mr.Tools,
Have you had the chance to review my request to implement the band? This indicator with the band will be very helpful to identify potential breakout, reversal and ranging market. At the moment, there is no mt4 TSV indicator with the band.


Re: Volume Indicators for MT4

546
Vinodh wrote: Mon Oct 17, 2022 11:01 am Hi Mr.Tools,
Have you had the chance to review my request to implement the band? This indicator with the band will be very helpful to identify potential breakout, reversal and ranging market. At the moment, there is no mt4 TSV indicator with the band.
Saw it, haven't been able to figure out how to do it.
These users thanked the author mrtools for the post:
simon_n3z

DownloadRe: Volume Indicators for MT4

547
mrtools wrote: Mon Oct 17, 2022 11:43 am Saw it, haven't been able to figure out how to do it.
Hi Mr.tools,
Thanks for the prompt response. Can you please explain what this logic does?
avg_inflow = sma(tsv > 0 ? tsv : na, tsv_bands_length)

I implemented as per the tradingview, but I am getting only one line but not the band. Even the line also doesn't look right. What I have noticed in the tradingview was that, when tsv > 0, the current lower band has the same value as the previous value. It is vice versa when tsv < 0. I showed in the pic below with black circle. I am not sure whether my observation provide you any clue to implement the band.
Attachments

Re: Volume Indicators for MT4

549
Vinodh wrote: Thu Oct 20, 2022 11:59 am Hi Mr.Tools,
When I was navigating the volume indicators here, I came across force index indicator that has the volatility band. I attached the file here. Is that possible to use that volatility band logic to the TSV indicator instead? Please let me know. Thanks.
Got this that doesn't look right to me.
Attachments
These users thanked the author mrtools for the post:
simon_n3z


Who is online

Users browsing this forum: amirvaighan1362, Bing [Bot], IBM oBot [Bot], knsxrty459, LevFJX, RodrigoRT7, TheJurgFX and 46 guests