Strategy testing

50
//+------------------------------------------------------------------+ //| Daily 10% Profit EA with 5% Max Drawdown | //| Uses RSI, Bollinger Bands, ADX, Fibonacci, Grid System | //+------------------------------------------------------------------+ //version=5 strategy("Daily 10% Profit EA", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// Input Parameters RSI_Period = input(14, "RSI Period") ADX_Period = input(14, "ADX Period") BB_Period = input(20, "Bollinger Bands Period") BB_Deviation = input(2, "Bollinger Bands Deviation") MaxDrawdownPercent = input(5, "Max Daily Drawdown (%)") DailyProfitTargetPercent = input(10, "Daily Profit Target (%)")

// Indicators rsi = ta.rsi(close, RSI_Period) adx = ta.adx(ADX_Period) bb_upper = ta.sma(close, BB_Period) + BB_Deviation * ta.stdev(close, BB_Period) bb_lower = ta.sma(close, BB_Period) - BB_Deviation * ta.stdev(close, BB_Period)

// Fibonacci Retracement Calculation highestHigh = ta.highest(high, 50) lowestLow = ta.lowest(low, 50) fibLevel = lowestLow + (highestHigh - lowestLow) * 0.382

// Strategy Conditions longCondition = (rsi < 30 and adx > 20 and close < bb_lower) shortCondition = (rsi > 70 and adx > 20 and close > bb_upper)

// Risk Management initialBalance = strategy.equity currentEquity = strategy.equity DailyProfit = ((currentEquity - initialBalance) / initialBalance) * 100 DailyDrawdown = ((initialBalance - currentEquity) / initialBalance) * 100

dailyLimitReached = (DailyProfit >= DailyProfitTargetPercent or DailyDrawdown >= MaxDrawdownPercent)

if longCondition and not dailyLimitReached strategy.entry("Long", strategy.long) if shortCondition and not dailyLimitReached strategy.entry("Short", strategy.short)

// Close trades when daily limits are reached if dailyLimitReached strategy.close_all()

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.