OPEN-SOURCE SCRIPT

Strategy by Nachi Chennai

//version=5
indicator("EMA Scalping Strategy", overlay=true)

// Input for EMA settings
ema_short = input.int(9, title="Short EMA", minval=1)
ema_medium = input.int(21, title="Medium EMA", minval=1)
ema_long = input.int(50, title="Long EMA", minval=1)

// EMA calculations
shortEMA = ta.ema(close, ema_short)
mediumEMA = ta.ema(close, ema_medium)
longEMA = ta.ema(close, ema_long)

// Input for RSI settings
rsi_length = input.int(14, title="RSI Length", minval=1)
rsi_overbought = input.int(70, title="RSI Overbought Level", minval=50)
rsi_oversold = input.int(30, title="RSI Oversold Level", minval=1)

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

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

// Conditions for Buy and Sell
buyCondition = ta.crossover(shortEMA, mediumEMA) and close > longEMA and rsi > 50 and macdLine > signalLine
sellCondition = ta.crossunder(shortEMA, mediumEMA) and close < longEMA and rsi < 50 and macdLine < signalLine

// Plotting EMAs
plot(shortEMA, color=color.new(color.blue, 0), title="Short EMA (9)")
plot(mediumEMA, color=color.new(color.orange, 0), title="Medium EMA (21)")
plot(longEMA, color=color.new(color.red, 0), title="Long EMA (50)")

// Plot Buy and Sell signals
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="SELL")

// Background Highlighting
bgcolor(buyCondition ? color.new(color.green, 90) : na, title="Buy Highlight")
bgcolor(sellCondition ? color.new(color.red, 90) : na, title="Sell Highlight")

Wyłączenie odpowiedzialności