OPEN-SOURCE SCRIPT

TMC Strategy - Simplified Buy/Sell Signals

293
//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)

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.