user20537640
user20537640

Reputation: 15

How to highlight the price when a candle crosses the previous candle which is closed above EMA100 line?

I'm new to pine script and I am trying to figure out how to make an indicator highlighting:

Price when the current candle cross below the wick low of previous candle + previous candle should be completely detached (even the wick) above the EMA100 line

Please help anyone :)

I tried something like this but it doesn't work :(

ema100 = ta.ema(close, 100) emaGapBelow = high < ema100 emaGapAbove = low > ema100 entryCandle = close < emaGapAbove

plotshape(entryCandle)

Upvotes: 1

Views: 607

Answers (1)

G.Lebret
G.Lebret

Reputation: 3078

In pinescript the number in brackets is used to acces previous data. For example to get the previous low, you use :

low[1]

For your code, you should try :

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

if currentcrossbelow and previousdetached
    // Here, your conditions are met

Upvotes: 1

Related Questions