engulfing candle cross EMA
Posted: Fri Mar 31, 2023 4:28 pm
Hello all,
I am new to pine script and am trying to create my first script.
Idea is to plot shape once bullEC or bearEC crosses over or under the EMA. Below you can see how I tried to do this, but it is plotting shape on every candle not just engulfing one.
If anyone can help me how to fix this, I would really appreciate it.
//Engaulfing candle
bullEC = open <= close[1] and close > open[1]
bearEC = open >= close[1] and close < open[1]
// Get ATR value
atr = ta.atr(14)
//Up and Down trend
uptrend = close > ema1 and ema1 > ema2
downtrend = close < ema1 and ema1 < ema2
//Buy and Sell conditions
buySignal = bullEC and uptrend
sellSignal = bearEC and downtrend
best regards
I am new to pine script and am trying to create my first script.
Idea is to plot shape once bullEC or bearEC crosses over or under the EMA. Below you can see how I tried to do this, but it is plotting shape on every candle not just engulfing one.
If anyone can help me how to fix this, I would really appreciate it.
//Engaulfing candle
bullEC = open <= close[1] and close > open[1]
bearEC = open >= close[1] and close < open[1]
// Get ATR value
atr = ta.atr(14)
//Up and Down trend
uptrend = close > ema1 and ema1 > ema2
downtrend = close < ema1 and ema1 < ema2
//Buy and Sell conditions
buySignal = bullEC and uptrend
sellSignal = bearEC and downtrend
best regards