// Define Short-term and Long-term MAs shortTermMA = ta.sma(close, 9) longTermMA = ta.sma(close, 21)
// Define RSI rsi = ta.rsi(close, 14)
// Define Volume volumeMA = ta.sma(volume, 20)
// Define Buy and Sell Conditions based on MA Crossovers, RSI, and Volume buyCondition = ta.crossover(shortTermMA, longTermMA) and rsi < 30 and volume > volumeMA sellCondition = ta.crossunder(shortTermMA, longTermMA) and rsi > 70 and volume > volumeMA
// Detect Bullish Engulfing Pattern bullishEngulfing = (open[1] > close[1]) and (close > open) and (close > high[1]) and (open < low[1])
// Detect Bearish Engulfing Pattern bearishEngulfing = (open[1] < close[1]) and (close < open) and (close < low[1]) and (open > high[1])
// Combine all Buy and Sell Conditions finalBuyCondition = buyCondition or bullishEngulfing finalSellCondition = sellCondition or bearishEngulfing
// Plot Short-term and Long-term MA plot(shortTermMA, "Short Term MA", color=color.blue, linewidth=2) plot(longTermMA, "Long Term MA", color=color.red, linewidth=2)
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.