//@version=6 strategy("SSL Hybrid Pro v6.1", overlay=true, margin_long=100, margin_short=100, commission_type=strategy.commission.percent, commission_value=0.075, pyramiding=1, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=1) // Enhanced Inputs inputPeriod = input.int(8, title="SSL Period", minval=1, maxval=20) inputSmoothing = input.int(2, title="Smoothing Factor", minval=1, maxval=5) inputTrailingStop = input.float(1.0, title="Trailing Stop (%)", minval=0.5, step=0.1, maxval=3) inputRiskReward = input.float(3.0, title="Risk/Reward Ratio", minval=1.5, step=0.1, maxval=5) inputUseNewsFilter = input.bool(true, title="Use News Filter") inputAutoTrade = input.bool(true, title="Enable Auto-Trading", group="Auto-Trading") inputMaxTrades = input.int(3, title="Max Open Trades", minval=1, maxval=10, group="Risk Management") // Enhanced SSL Hybrid with Adaptive Filtering hmaFast = ta.hma(close, inputPeriod) hmaSlow = ta.wma(close, inputPeriod * 2) sslBaseUp = ta.ema(hmaFast > hmaSlow ? hmaFast : hmaSlow, inputSmoothing) sslBaseDown = ta.ema(hmaFast < hmaSlow ? hmaFast : hmaSlow, inputSmoothing) // Adaptive SSL Filter based on volatility atrValue = ta.atr(14) atrRatio = atrValue / close * 100 volatilityFactor = math.max(1, math.min(3, atrRatio * 3)) sslUp = sslBaseUp + (atrValue * 0.5 * volatilityFactor) sslDown = sslBaseDown - (atrValue * 0.5 * volatilityFactor) // Multi-Timeframe SuperTrend Confirmation supertrendDir = request.security(syminfo.tickerid, "15", ta.supertrend(3, 10)[1]) supertrendDirection = supertrendDir[1] > close ? -1 : 1 // Volume Weighted Trend Confirmation volumeAvg = ta.sma(volume, 20) volumeFactor = volume > volumeAvg * 1.5 ? 1.5 : volume > volumeAvg ? 1 : 0.5 trendDirection = supertrendDirection * volumeFactor // Candlestick Pattern Confirmation engulfingBullish = close[1] < open[1] and close > open and close > open[1] and open < close[1] engulfingBearish = close[1] > open[1] and close < open and close < open[1] and open > close[1] // Enhanced Entry Conditions with Multiple Confirmations rsiValue = ta.rsi(close, 14) macdLine = ta.ema(close, 12) - ta.ema(close, 26) macdSignal = ta.ema(macdLine, 9) longCondition = close > sslUp and trendDirection > 0 and rsiValue > 50 and macdLine > macdSignal and (engulfingBullish or close > open[1]) shortCondition = close < sslDown and trendDirection < 0 and rsiValue < 50 and macdLine < macdSignal and (engulfingBearish or close < open[1]) // Auto-Trading Conditions autoTradeLong = longCondition and inputAutoTrade and strategy.opentrades < inputMaxTrades autoTradeShort = shortCondition and inputAutoTrade and strategy.opentrades < inputMaxTrades // Enhanced Exit Conditions with Dynamic Trailing var float longTrailPrice = na var float shortTrailPrice = na trailOffset = inputTrailingStop * 0.01 * close if longCondition or strategy.position_size > 0 longTrailPrice := math.max(nz(longTrailPrice), close - trailOffset) if shortCondition or strategy.position_size < 0 shortTrailPrice := math.min(nz(shortTrailPrice), close + trailOffset) // Adaptive Position Sizing with Volatility Adjustment basePositionSize = strategy.equity * 0.01 / (close * 0.01) volatilityAdjustment = 1 / math.max(0.5, math.min(2, atrRatio)) positionSize = basePositionSize * volatilityAdjustment // Dynamic Take Profit based on recent ATR atrMultiplier = inputRiskReward * (1 + (ta.change(atrValue) / atrValue)) takeProfitLong = close + (atrValue * atrMultiplier) takeProfitShort = close - (atrValue * atrMultiplier) // Win Rate Tracking var int totalTrades = 0 var int winningTrades = 0 if strategy.closedtrades > 0 totalTrades := totalTrades + 1 if strategy.closedtrades.profit(strategy.closedtrades-1) > 0 winningTrades := winningTrades + 1 // News Filter with Economic Calendar Integration isNewsTime = dayofweek == dayofweek.friday and hour >= 13 and hour <= 15 // Enhanced Strategy Execution with Time Filters isOptimalTime = (hour >= 8 and hour <= 18) or (dayofweek != dayofweek.saturday and dayofweek != dayofweek.sunday) if time > timestamp(2020, 1, 1, 0, 0) if autoTradeLong and (not inputUseNewsFilter or not isNewsTime) and barstate.isconfirmed and isOptimalTime strategy.entry("Long", strategy.long, qty=positionSize) strategy.exit("Long Exit", "Long", stop=longTrailPrice, limit=takeProfitLong, trail_points=close * 0.005, trail_offset=close * 0.003) if autoTradeShort and (not inputUseNewsFilter or not isNewsTime) and barstate.isconfirmed and isOptimalTime strategy.entry("Short", strategy.short, qty=positionSize) strategy.exit("Short Exit", "Short", stop=shortTrailPrice, limit=takeProfitShort, trail_points=close * 0.005, trail_offset=close * 0.003) // Enhanced Plotting with Candlestick Alignment plot(sslUp, color=color.new(color.green, 0), linewidth=2, title="SSL Up") plot(sslDown, color=color.new(color.red, 0), linewidth=2, title="SSL Down") // Visual Indicators plotshape(longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small) plotshape(shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small) // Dashboard and Reporting var table statsTable = table.new(position.top_right, 5, 6, border_width=1) if barstate.islast table.cell(statsTable, 0, 0, "Performance", bgcolor=color.gray) table.cell(statsTable, 1, 0, "Value", bgcolor=color.gray) table.cell(statsTable, 0, 1, "Win Rate", bgcolor=color.new(color.gray, 80)) table.cell(statsTable, 1, 1, str.tostring(math.round(winningTrades/math.max(1,totalTrades)*100))+"%", bgcolor=color.new(color.gray, 80)) table.cell(statsTable, 0, 2, "Profit Factor", bgcolor=color.new(color.gray, 80)) table.cell(statsTable, 1, 2, str.tostring(math.round(strategy.grossprofit/math.max(1,strategy.grossloss), 2)), bgcolor=color.new(color.gray, 80)) table.cell(statsTable, 0, 3, "Max Drawdown", bgcolor=color.new(color.gray, 80)) table.cell(statsTable, 1, 3, str.tostring(math.round(strategy.max_drawdown, 2))+"%", bgcolor=color.new(color.gray, 80)) table.cell(statsTable, 0, 4, "Open Trades", bgcolor=color.new(color.gray, 80)) table.cell(statsTable, 1, 4, str.tostring(strategy.opentrades), bgcolor=color.new(color.gray, 80)) // Auto-Trading Alerts alertcondition(autoTradeLong, title="Auto Buy Signal", message="SSL Hybrid Pro Buy Signal") alertcondition(autoTradeShort, title="Auto Sell Signal", message="SSL Hybrid Pro Sell Signal")