'Darva's Box on Renko doing Weird Stuff
Could anyone help me understand why sometimes this indicator fires a Buy/Sell alert without plotting Buy/Sell on the chart and other times plots a Buy/Sell on the chart without firing a Buy/Sell alert? This is specifically on Renko Traditional set to 0.0012 for forex instruments. Any input is appreciated.
//@version=5
indicator('Darvas Box Buy Sell', overlay=true)
boxp = input.int(defval=5, title='Length', minval=1, maxval=500)
LL = ta.lowest(low, boxp)
k1 = ta.highest(high, boxp)
k2 = ta.highest(high, boxp - 1)
k3 = ta.highest(high, boxp - 2)
NH = ta.valuewhen(high > k1[1], high, 0)
box1 = k3 < k2
TopBox = ta.valuewhen(ta.barssince(high > k1[1]) == boxp - 2 and box1, NH, 0)
BottomBox = ta.valuewhen(ta.barssince(high > k1[1]) == boxp - 2 and box1, LL, 0)
plot(TopBox, linewidth=2, color=color.new(#4CAF50, 0), title='TBbox')
plot(BottomBox, linewidth=2, color=color.new(#FF0000, 0), title='BBbox')
Buy = ta.crossover(close, TopBox)
Sell = ta.crossunder(close, BottomBox)
alertcondition(Buy, title='Buy Signal', message='Buy')
alertcondition(Sell, title='Sell Signal', message='Sell')
plotshape(Buy, style=shape.labelup, location=location.belowbar, color=color.new(#4CAF50, 0), size=size.tiny, title='Buy Signal', text='Buy', textcolor=color.new(color.black, 0))
plotshape(Sell, style=shape.labeldown, location=location.abovebar, color=color.new(#FF0000, 0), size=size.tiny, title='Sell Signal', text='Sell', textcolor=color.new(color.white, 0))
Solution 1:[1]
Because Renko bar prices are synthetic and they do not reflect market prices at any precise moment in time, as normal bars do,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vitruvius |
