OPEN-SOURCE SCRIPT

EMA Crossover + RSI Filter (1-Hour)

//version=5
strategy("EMA Crossover + RSI Filter (1-Hour)", overlay=true)

// Input parameters
fastLength = input.int(9, title="Fast EMA Length")
slowLength = input.int(21, title="Slow EMA Length")
rsiLength = input.int(14, title="RSI Length")
overbought = input.int(70, title="Overbought Level")
oversold = input.int(30, title="Oversold Level")

// Calculate EMAs
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)

// Calculate RSI
rsi = ta.rsi(close, rsiLength)

// Buy Condition
buyCondition = ta.crossover(fastEMA, slowEMA) and rsi > 50 and rsi < overbought

// Sell Condition
sellCondition = ta.crossunder(fastEMA, slowEMA) and rsi < 50 and rsi > oversold

// Plot EMAs
plot(fastEMA, color=color.blue, title="Fast EMA")
plot(slowEMA, color=color.red, title="Slow EMA")

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

// Execute Trades
if (buyCondition)
strategy.entry("Buy", strategy.long)

if (sellCondition)
strategy.entry("Sell", strategy.short)

免责声明