0

i want to trigger an alert or plot hline as soon as below conditions are met:

  1. the current candle did not cut the previous candle high
  2. the current candle price cuts below the low of previous candle
  3. the current candle is about to close (say 95% of time is passed)

Please help me :)

I am new to pinescript, trying to learn each day, so far i have below

ema100 = ta.ema(close,100)
currentcrossbelow = close < low[1]
previousdetached = low[1] > ema100[1]

    
bgcolor(currentcrossbelow and previousdetached ? color.new(color.green, 40) : na)
plot(ema100)

1 Answers1

0

Pinescript will execute your indicator on each historical bar.
It means that for the historical bar, you will have the value (Open, Close, High, Low) once the bar is closed.
So on historical bar, you can't know when a bar 'is going to close'
The only turnaround you can use is to choose a more precise timeframe.

G.Lebret
  • 2,826
  • 2
  • 16
  • 27