OPEN-SOURCE SCRIPT

Multi-Timeframe Trend Strategy

//version=5
indicator("Multi-Timeframe Trend Strategy", overlay=true)

// Inputs for EMA
ema50_length = input(50, title="50 EMA Length")
ema200_length = input(200, title="200 EMA Length")

// Inputs for RSI
rsi_length = input(14, title="RSI Length")
rsi_overbought = input(70, title="RSI Overbought Level")
rsi_oversold = input(30, title="RSI Oversold Level")

// EMA calculations
ema50 = ta.ema(close, ema50_length)
ema200 = ta.ema(close, ema200_length)

// RSI calculation
rsi = ta.rsi(close, rsi_length)

// MACD calculations
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)

// Plot EMAs
plot(ema50, color=color.blue, linewidth=2, title="50 EMA")
plot(ema200, color=color.red, linewidth=2, title="200 EMA")

// Conditions for Long Entry
long_condition = (close > ema200) and (ta.crossover(close, ema50)) and (rsi > 50 and rsi < rsi_overbought) and (macdLine > signalLine)

// Conditions for Short Entry
short_condition = (close < ema200) and (ta.crossunder(close, ema50)) and (rsi < 50 and rsi > rsi_oversold) and (macdLine < signalLine)

// Plot Buy/Sell Signals
plotshape(long_condition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", title="Buy Signal")
plotshape(short_condition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", title="Sell Signal")

// Alerts
alertcondition(long_condition, title="Long Alert", message="Buy Signal Detected!")
alertcondition(short_condition, title="Short Alert", message="Sell Signal Detected!")
Candlestick analysisChart patternsCycles

Open-source script

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.

Want to use this script on a chart?

Disclaimer