BTC Ema Crossover (Rsi+adx)
BTC Ema Crossover (Rsi+adx)
// Inputs
rsiPeriod = input.int(7, "RSI Period", minval=1)
rsiOverbought = input.int(70, "RSI Overbought", minval=1)
rsiOversold = input.int(30, "RSI Oversold", minval=1)
adxPeriod = input.int(14, "ADX Period", minval=1)
adxThreshold = input.int(30, "ADX Threshold", minval=1) // Increased from 25 to 30
emaFastPeriod = input.int(5, "EMA Fast Period", minval=1)
emaSlowPeriod = input.int(21, "EMA Slow Period", minval=1)
emaTrendPeriod = input.int(50, "EMA Trend Period", minval=1) // Added trend EMA
atrPeriod = input.int(14, "ATR Period", minval=1)
targetMultiplier = input.float(1.5, "Target Multiplier (Risk:Reward)",
minval=1.0) // Reduced from 2.0 to 1.5
// Calculations
// RSI
rsi = ta.rsi(close, rsiPeriod)
rsiRising = rsi > rsi[1] // RSI increasing for buy confirmation
rsiFalling = rsi < rsi[1] // RSI decreasing for sell confirmation
// EMAs
emaFast = ta.ema(close, emaFastPeriod)
emaSlow = ta.ema(close, emaSlowPeriod)
emaTrend = ta.ema(close, emaTrendPeriod) // Trend filter
if buySignal
buySL := low - atr
buyTarget := close + (close - buySL) * targetMultiplier
if sellSignal
sellSL := high + atr
sellTarget := close - (sellSL - close) * targetMultiplier
if buyEntry
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", "Long", stop=buySL, profit=buyTarget)
if sellEntry
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", "Short", stop=sellSL, profit=sellTarget)
// Plot Signals
plotshape(buySignal, title="Buy Signal", location=location.belowbar,
color=color.green, style=shape.triangleup, size=size.small)
plotshape(sellSignal, title="Sell Signal", location=location.abovebar,
color=color.red, style=shape.triangledown, size=size.small)
// Plot EMAs
plot(emaFast, "EMA Fast", color=color.green, linewidth=2)
plot(emaSlow, "EMA Slow", color=color.red, linewidth=2)
plot(emaTrend, "EMA Trend", color=color.blue, linewidth=1) // Added trend EMA plot