OPEN-SOURCE SCRIPT

TMC Strategy - Simplified Buy/Sell Signals

338
//version=5
indicator("TMC Strategy - Simplified Buy/Sell Signals", overlay=true)

// Input parameters
emaLength = input.int(20, title="EMA Length")
rsiLength = input.int(10, title="RSI Length")
macdFast = input.int(12, title="MACD Fast Length")
macdSlow = input.int(26, title="MACD Slow Length")
macdSignal = input.int(9, title="MACD Signal Length")

// Calculate indicators
ema = ta.ema(close, emaLength)
rsi = ta.rsi(close, rsiLength)
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignal)

// Trend condition
uptrend = close > ema
downtrend = close < ema

// Momentum condition
rsiBullish = rsi > 50
rsiBearish = rsi < 50

// MACD condition
macdBullish = ta.crossover(macdLine, signalLine)
macdBearish = ta.crossunder(macdLine, signalLine)

// Buy and Sell Signals
buySignal = uptrend and rsiBullish and macdBullish
sellSignal = downtrend and rsiBearish and macdBearish

// Plot Buy and Sell Signals
plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small)
plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small)

// Optional: Plot EMA for visual reference
plot(ema, title="EMA", color=color.blue, linewidth=2)

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.