-
Notifications
You must be signed in to change notification settings - Fork 48
Description
following script not working, can anyone fix bugs
instrument {
name = 'EURUSD 15m PRO',
icon = 'indicators:SUPER_TREND',
overlay = true
}
// INPUT PARAMETERS ====================================
input_group {
"Bollinger Bands",
bbLength = input(20, "Period"),
bbDeviation = input(2.0, "Std Dev")
}
input_group {
"Parabolic SAR",
sarStep = input(0.02, "Step"),
sarMax = input(0.2, "Max")
}
input_group {
"Moving Average",
maLength = input(50, "EMA Period")
}
input_group {
"RSI Settings",
rsiLength = input(14, "Period"),
rsiOverbought = input(80, "Sell Level"),
rsiOversold = input(20, "Buy Level")
}
input_group {
"SuperTrend",
stLength = input(10, "ATR Period"),
stMultiplier = input(3.0, "Multiplier")
}
// CALCULATIONS ========================================
// 1. Bollinger Bands
basis = sma(close, bbLength)
upperBB = basis + (stdev(close, bbLength) * bbDeviation)
lowerBB = basis - (stdev(close, bbLength) * bbDeviation)
// 2. Parabolic SAR
sar = parabolicSAR(sarStep, sarMax)
// 3. EMA Filter
ema50 = ema(close, maLength)
// 4. RSI Filter
rsi = rsi(close, rsiLength)
// 5. Non-Repainting SuperTrend
atrValue = atr(stLength)
upperBand = hl2 + (stMultiplier * atrValue)
lowerBand = hl2 - (stMultiplier * atrValue)
superTrend = close > superTrend[1] ? max(lowerBand, superTrend[1]) : min(upperBand, superTrend[1])
trendDirection = close > superTrend ? 1 : -1
// SIGNAL GENERATION ===================================
// Buy Conditions (ALL must be true)
buySignal = crossover(close, lowerBB) and // Price crosses lower BB
close > ema50 and // Above 50 EMA
rsi > rsiOversold and // RSI exits oversold
sar < close and // SAR below price
trendDirection == 1 and // Uptrend confirmed
barstate.isconfirmed // Only on closed candles
// Sell Conditions (ALL must be true)
sellSignal = crossunder(close, upperBB) and // Price crosses upper BB
close < ema50 and // Below 50 EMA
rsi < rsiOverbought and // RSI exits overbought
sar > close and // SAR above price
trendDirection == -1 and // Downtrend confirmed
barstate.isconfirmed // Only on closed candles
// VISUALIZATION ======================================
// Plot Indicators
plot(upperBB, "Upper BB", #2196F3, 1)
plot(lowerBB, "Lower BB", #2196F3, 1)
plot(sar, "SAR", #FFC107, 2)
plot(ema50, "EMA 50", #00BCD4, 2)
plot(superTrend, "SuperTrend", trendDirection == 1 ? #4CAF50 : #FF5252, 2)
// Plot Signals (Non-Repainting)
plotshape(buySignal, "BUY", shape.triangleup, location.belowbar, #4CAF50, 0, "BUY")
plotshape(sellSignal, "SELL", shape.triangledown, location.abovebar, #FF5252, 0, "SELL")
// RSI Background Alert
bgcolor(rsi >= rsiOverbought ? color.new(#FF5252, 90) :
rsi <= rsiOversold ? color.new(#4CAF50, 90) : na)