I simply need someone to add a part to the end of the below script that adds upward buy arrows with 'buy' alert conditions for this Volatility Stop indicator.
The main condition is that I don't want a green buy arrow to appear at every green cross, I only want it to appear once at the beginning of a run of green crosses / after each run of red crosses.
Below is the code. Should be a 5 minute job to someone who knows Pine script. Not a big job as I am already providing the bulk of the code for this indicator. Also I have attached an image with an example of where I want the arrows to make things clearer. Thanks!
study("Volatility Stop Custom", shorttitle="VStop", overlay=false)
length = input(20)
mult = input(2)
atr_ = atr(length)
is_uptrend_prev = false
max_ = 0.0
min_ = 0.0
max1 := max(nz(max_), close)
min1 := min(nz(min_), close)
is_uptrend_prev := nz(is_uptrend, true)
stop := is_uptrend_prev ? max1 - mult * atr_ : min1 + mult * atr_
vstop_prev := nz(vstop)
vstop1 := is_uptrend_prev ? max(vstop_prev, stop) : min(vstop_prev, stop)
is_uptrend := close - vstop1 >= 0
is_trend_changed := is_uptrend != is_uptrend_prev
max_ := is_trend_changed ? close : max1
min_ := is_trend_changed ? close : min1
vstop := is_trend_changed ? is_uptrend ? max_ - mult * atr_ : min_ + mult * atr_ : vstop1
plot(vstop, color = is_uptrend ? green : red, style=cross, linewidth=2)
7 freelancers are bidding on average $189 for this job