Reputation: 119
I need some help to offset my alert by 1 I'm able to offset the arrow (plotted) but I can't figure out how to offset the actual alert so it comes on the next candle (so the cross is confirmed)
tavg = tos == 1 ? avg(a,avg) : avg(b,avg)
tavgi = tosi == 1 ? avg(ai,avgi) : avg(bi,avgi)
enterLong = crossover(tavgi, tavg)
enterShort = crossunder(tavgi, tavg)
alertcondition(enterLong, title='Long', message='long tradesymbol=EURUSD')
alertcondition(enterShort, title='Short', message='short tradesymbol=EURUSD')
How to add an offset=1 to enterLong and enterShort
I tried
enterLong = crossover(tavgi, tavg)
barcolor(color=enterLong ? blue : na, offset=1)
alertcondition(condition=enterLong,
message="long tradesymbol=EURUSD")
enterShort = crossunder(tavgi, tavg)
barcolor(color=enterShort ? orange : na, offset=1)
alertcondition(condition=enterShort,
message="short tradesymbol=EURUSD")
but it obviously only offset only the barcolor not the alert :(
Sorry I can't put the whole code but if you have an idea it would be highly appreciated thanks
Upvotes: 0
Views: 608
Reputation: 2568
This can be done via the history operator []
, checking the condition on the previous bar:
alertcondition(enterLong[1], title='Long', message='long tradesymbol=EURUSD')
alertcondition(enterShort[1], title='Short', message='short tradesymbol=EURUSD')
Upvotes: 1