OPEN-SOURCE SCRIPT
My script

/version=5
indicator("dvp - Engulfing Strategy", overlay=true)
// Moving Averages
sma1 = input.int(6,"Trend SMA")
ema1 = input.int(3,"Engulf EMA")
sma6 = ta.sma(close, sma1)
ema3 = ta.ema(close, ema1)
// Helper candles
c3 = close[2] < open[2] // 3 days ago was a red candle
c2 = close[1] > open[1] // 2 days ago was a green candle
engulfed = (low[1] < low[2]) and (high[1] > high[2]) // bullish engulfing
c0_bull = close > open // current candle is green
close_above_c2high = close > high[1]
c3_below_sma6 = close[2] < sma6[2]
c0_above_ema3 = close > ema3
// Bullish Engulfing Conditions
bullishSignal = c3 and c2 and engulfed and c0_bull and close_above_c2high and c3_below_sma6 and c0_above_ema3
// Plotting text for bullish engulfing
plotshape(bullishSignal, title="Bullish Engulfing", location=location.belowbar, color=color.green, style=shape.labelup, text="BuE")
// Optional: Bearish Engulfing Detection
c3_bear = close[2] > open[2] // 3 days ago green
c2_bear = close[1] < open[1] // 2 days ago red
engulfed_bear = (high[1] > high[2]) and (low[1] < low[2])
c0_bear = close < open // current red
close_below_c2low = close < low[1]
c3_above_sma6 = close[2] > sma6[2]
c0_below_ema3 = close < ema3
bearishSignal = c3_bear and c2_bear and engulfed_bear and c0_bear and close_below_c2low and c3_above_sma6 and c0_below_ema3
plotshape(bearishSignal, title="Bearish Engulfing", location=location.abovebar, color=color.red, style=shape.labeldown, text="BeU")
// Plotting Moving Averages
plot(sma6, color=color.orange, title="SMA 6")
plot(ema3, color=color.blue, title="EMA 3")
```
indicator("dvp - Engulfing Strategy", overlay=true)
// Moving Averages
sma1 = input.int(6,"Trend SMA")
ema1 = input.int(3,"Engulf EMA")
sma6 = ta.sma(close, sma1)
ema3 = ta.ema(close, ema1)
// Helper candles
c3 = close[2] < open[2] // 3 days ago was a red candle
c2 = close[1] > open[1] // 2 days ago was a green candle
engulfed = (low[1] < low[2]) and (high[1] > high[2]) // bullish engulfing
c0_bull = close > open // current candle is green
close_above_c2high = close > high[1]
c3_below_sma6 = close[2] < sma6[2]
c0_above_ema3 = close > ema3
// Bullish Engulfing Conditions
bullishSignal = c3 and c2 and engulfed and c0_bull and close_above_c2high and c3_below_sma6 and c0_above_ema3
// Plotting text for bullish engulfing
plotshape(bullishSignal, title="Bullish Engulfing", location=location.belowbar, color=color.green, style=shape.labelup, text="BuE")
// Optional: Bearish Engulfing Detection
c3_bear = close[2] > open[2] // 3 days ago green
c2_bear = close[1] < open[1] // 2 days ago red
engulfed_bear = (high[1] > high[2]) and (low[1] < low[2])
c0_bear = close < open // current red
close_below_c2low = close < low[1]
c3_above_sma6 = close[2] > sma6[2]
c0_below_ema3 = close < ema3
bearishSignal = c3_bear and c2_bear and engulfed_bear and c0_bear and close_below_c2low and c3_above_sma6 and c0_below_ema3
plotshape(bearishSignal, title="Bearish Engulfing", location=location.abovebar, color=color.red, style=shape.labeldown, text="BeU")
// Plotting Moving Averages
plot(sma6, color=color.orange, title="SMA 6")
plot(ema3, color=color.blue, title="EMA 3")
```
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。