//@version=6 strategy("Aggressive Bear Market Short Strategy - V6 (Aggressive Conditions)", overlay=true, initial_capital=10000, currency=currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=2) // Reduced position size // === INPUTS === // Trend Confirmation: Simple Moving Average smaPeriod = input.int(title="SMA Period", defval=50, minval=1) // RSI Parameters rsiPeriod = input.int(title="RSI Period", defval=14, minval=1) rsiAggThreshold = input.int(title="Aggressive RSI Threshold", defval=50, minval=1, maxval=100) // MACD Parameters macdFast = input.int(title="MACD Fast Length", defval=12, minval=1) macdSlow = input.int(title="MACD Slow Length", defval=26, minval=1) macdSignalL = input.int(title="MACD Signal Length", defval=9, minval=1) // Bollinger Bands Parameters bbLength = input.int(title="Bollinger Bands Length", defval=20, minval=1) bbStdDev = input.float(title="BB StdDev Multiplier", defval=2.0, step=0.1) // Stochastic Oscillator Parameters stochLength = input.int(title="Stochastic %K Length", defval=14, minval=1) stochSmooth = input.int(title="Stochastic %D Smoothing", defval=3, minval=1) stochAggThreshold = input.int(title="Aggressive Stochastic Threshold", defval=70, minval=1, maxval=100) // ADX Parameters adxPeriod = input.int(title="ADX Period", defval=14, minval=1) adxAggThreshold = input.float(title="Aggressive ADX Threshold", defval=20.0, step=0.1) // Risk Management stopLossPercent = input.float(title="Stop Loss (%)", defval=0.5, step=0.1) takeProfitPercent = input.float(title="Take Profit (%)", defval=0.3, step=0.1) trailingStopPercent = input.float(title="Trailing Stop (%)", defval=0.3, step=0.1) // === INDICATOR CALCULATIONS === // 1. SMA for overall trend determination. smaValue = ta.sma(close, smaPeriod) // 2. RSI calculation. rsiValue = ta.rsi(close, rsiPeriod) // 3. MACD calculation. [macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignalL) // 4. Bollinger Bands calculation. bbBasis = ta.sma(close, bbLength) bbDev = bbStdDev * ta.stdev(close, bbLength) bbUpper = bbBasis + bbDev bbLower = bbBasis - bbDev // 5. Stochastic Oscillator calculation. k = ta.stoch(close, high, low, stochLength) d = ta.sma(k, stochSmooth) // 6. ADX calculation. [diPlus, diMinus, adxValue] = ta.adx(high, low, close, adxPeriod) // Using built-in function // === AGGRESSIVE SIGNAL CONDITIONS === // Mandatory Bearish Condition: Price must be below the SMA. bearTrend = close < smaValue // Aggressive MACD Condition macdSignalFlag = macdLine < signalLine // Aggressive RSI Condition rsiSignalFlag = rsiValue > rsiAggThreshold // Aggressive Bollinger Bands Condition bbSignalFlag = close > bbUpper // Aggressive Stochastic Condition stochSignalFlag = ta.crossunder(k, stochAggThreshold) // Aggressive ADX Condition adxSignalFlag = adxValue > adxAggThreshold // Count the number of indicator signals that are true (Weighted). signalWeight = 0.0 if macdSignalFlag signalWeight := signalWeight + 0.25 if rsiSignalFlag signalWeight := signalWeight + 0.15 if bbSignalFlag signalWeight := signalWeight + 0.2 if stochSignalFlag signalWeight := signalWeight + 0.15 if adxSignalFlag signalWeight := signalWeight + 0.25 // Take a short position if the bear market condition is met and the signal weight is high enough. if bearTrend and (signalWeight >= 0.5) strategy.entry("Short", strategy.short) // === EXIT CONDITIONS === // Dynamic Trailing Stop Loss if strategy.position_size < 0 strategy.exit("Exit Short", from_entry = "Short", stop = math.max(strategy.position_avg_price * (1 + stopLossPercent / 100), high - high * trailingStopPercent / 100), limit= strategy.position_avg_price * (1 - takeProfitPercent / 100)) // === PLOTTING === plot(smaValue, color=color.orange, title="SMA") plot(bbUpper, color=color.blue, title="Bollinger Upper Band") plot(bbBasis, color=color.gray, title="Bollinger Basis") plot(bbLower, color=color.blue, title="Bollinger Lower Band") plot(adxValue, title="ADX", color=color.fuchsia) // Optional: Plot RSI and a horizontal line at the aggressive RSI threshold. plot(rsiValue, title="RSI", color=color.purple) hline(rsiAggThreshold, title="Aggressive RSI Threshold", color=color.red)