someone help correct the error on my pine script(tradingview).
When there is a bullish engulfing pattern on higher timeframe and a bearish engulfing on a lower timeframe. it should plot and send a signal.
i dont know where the problem currently is kindly help me
//@version=5
indicator("Engulfing Candles", overlay = true)
//strategy("Engulfing Candles") //keep this commented out unless backtesting
Trend = input.timeframe("W", "Trend", tooltip = "Trend Timeframe", group = "Settings")
Counter = input.timeframe("D", "Counter", tooltip = "Counter Timeframe", group = "Settings")
bullishEngulfing =(open[1] > close[1] and close > open and close >= open[1] and close[1] >= open and close - open > open[1] - close[1] )
bearishEngulfing = (close[1] > open[1] and open > close and open >= close[1] and open[1] >= close and open - close > close[1] - open[1] )
//===============TREND ENGULFING=========================//
Trend_bullish = request.security(syminfo.tickerid, Trend, bullishEngulfing, lookahead = barmerge.lookahead_on)
Trend_bearish = request.security(syminfo.tickerid, Trend, bearishEngulfing, lookahead = barmerge.lookahead_on)
//==============COUNTER ENGULFING=======================//
Counter_bullish = request.security(syminfo.tickerid, Counter, bullishEngulfing, lookahead = barmerge.lookahead_on)
Counter_bearish = request.security(syminfo.tickerid, Counter, bearishEngulfing, lookahead = barmerge.lookahead_on)
//==============TREND COUNTER CALCULATOR==============//
buy = Counter_bearish and Trend_bullish
plotshape(series = buy, text = "buy", textcolor = color.green, style = shape.triangleup, location = location.belowbar, color = color.green, size = size.tiny)
sell = Counter_bullish and Trend_bearish
plotshape(series = sell, text = "sell", textcolor = color.red, style = shape.triangledown, location = location.abovebar, color = color.red, size = size.tiny)
//============================ ALERT=========================================//
alertcondition(bullishEngulfing, title = "Bullish Engulfing", message = "[CurrencyPair] [TimeFrame], Bullish candle engulfing previous candle")
alertcondition(bearishEngulfing, title = "Bearish Engulfing", message = "[CurrencyPair] [TimeFrame], Bearish candle engulfing previous candle")
done with the coding but trying to figure out the problem
New contributor
Ato Attah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.