This is my first post so here it goes. I have recently picked up the pine script language and found for the most part to be intuitive. However, I'm stuck on a concept for the past week and I cant see how other codes have managed to achieve what I am trying to do. That being said the concept itself is very simple, and I can't see why it won't work. Essentially I am looking to set a real-time alert to indicate something has happened on a historical bar based on current conditions. The concept in question is, when I see a hammer, check if the previous bar was red. Then do nothing. If the next bar after the hammer closes green, then this is a legitimate hammer signal. Then go back and paint the hammer candle.
Im using the basic hammer script
Ham = input(title="Hammer", type=input.bool, defval=true)
bodySize = abs (open - close)
HlowerShadow = abs (low - open)
HupperShadow = abs (high - close)
Hammer = (HlowerShadow > bodySize * 2) and (low <= (lowest(low,10))) and (HlowerShadow > HupperShadow * 2) and (close <= open[1])
plotcandle (open,high,low,close, color=lookbackAlert ? #76FF7A : Hammer ? #1E90FF : na, bordercolor=na, wickcolor=na)
No problem to check bars before the hammer (prevbar = close[1] < open[1])
But is there a way to only 'repaint' a historical candle, based on current data? Any help or thoughts much appreciated
