//+------------------------------------------------------------------+ // Advanced…
- User
//+------------------------------------------------------------------+ //| Advanced Breakout EA (MT5) | //| Full Version with SL/TP Modes, Trailing, Risk, etc. | //+------------------------------------------------------------------+ #property strict #include <Trade/Trade.mqh> CTrade trade;
//--- INPUTS input int Breakout_Lookback = 20; input ENUM_TIMEFRAMES Timeframe = PERIOD_M15; input int EMA_Period = 50; input bool UseRSI = true; input int RSI_Period = 14; input double RSI_Buy_Level = 55.0; input double RSI_Sell_Level = 45.0;
//--- Risk and SL input double Risk_Percent = 1.0; input int SL_Mode = 1; // 1=Fixed, 2=ATR, 3=Breakout Candle, 4=Swing High/Low input int Fixed_SL = 50; input double ATR_Multiplier = 1.5; input int ATR_Period = 14;
//--- TP input int TP_Mode = 1; // 1=RR TP, 2=Trailing input double RR_Multiplier = 2.0;
//--- Trailing Stop input int TrailingMode = 1; // 1=Standard, 2=ATR input int Trailing_Stop = 50; input int Trail_Start = 30; input double ATR_Trail_Multiplier = 1.5; input int ATR_Trail_Period = 14;
//--- Control input int Max_Open_Positions = 1; input uint MagicNumber = 123456; input double Max_Daily_Drawdown_Percent = 5.0;
//--- Globals double DayStartEquity; bool TradingPaused = false; int lastCheckDay;
int OnInit() { DayStartEquity = AccountInfoDouble(ACCOUNT_EQUITY); MqlDateTime t; TimeToStruct(TimeLocal(), t); lastCheckDay = t.day; return(INIT_SUCCEEDED); }
void OnTick() { MqlDateTime t; TimeToStruct(TimeLocal(), t); if (t.day != lastCheckDay) { DayStartEquity = AccountInfoDouble(ACCOUNT_EQUITY); TradingPaused = false; lastCheckDay = t.day; }
double equity = AccountInfoDouble(ACCOUNT_EQUITY); double maxDrawdownEquity = DayStartEquity * (1.0 - Max_Daily_Drawdown_Percent / 100.0); if (equity < maxDrawdownEquity && !TradingPaused) { CloseAllPositions(); TradingPaused = true; Print("Daily drawdown limit reached. All positions closed."); return; } if (TradingPaused) return; if (PositionsTotalByMagic() >= Max_Open_Positions) return; string symbol = _Symbol; double ema = iMA(symbol, Timeframe, EMA_Period, 0, MODE_EMA, PRICE_CLOSE, 0); double close = iClose(symbol, Timeframe, 1); if (close > ema && NewBreakoutSignal(true)) OpenTrade(true); else if (close < ema && NewBreakoutSignal(false)) OpenTrade(false);}
bool NewBreakoutSignal(bool isBuy) { string symbol = _Symbol; double price = iClose(symbol, Timeframe, 1); double high = iHigh(symbol, Timeframe, iHighest(symbol, Timeframe, MODE_HIGH, Breakout_Lookback, 1)); double low = iLow(symbol, Timeframe, iLowest(symbol, Timeframe, MODE_LOW, Breakout_Lookback, 1));
return (isBuy && price > high) || (!isBuy && price < low); - Assistant
- User
'iMA' - wrong parameters count aaa.mq5 82 18 'SetTakeProfit' - undeclared identifier aaa.mq5 114 29 'tpPrice' - some operator expected aaa.mq5 114 43 'iATR' - wrong parameters count aaa.mq5 154 12 'iRSI' - wrong parameters count aaa.mq5 206 18 built-in: int iRSI(const string,ENUM_TIMEFRAMES,int,int) aaa.mq5 206 18
- Assistant
- User
updated full
- Assistant
- User
i said full
- Assistant
- User
'PositionSelectByIndex' - undeclared identifier aaa.mq5 240 12 'i' - some operator expected aaa.mq5 240 34 'PositionSelectByIndex' - undeclared identifier aaa.mq5 257 12 'i' - some operator expected aaa.mq5 257 34
- Assistant
The errors
'PositionSelectByIndex' - undeclared identifierand'i' - some operator expectedmean that the compiler does not recognize the function . - User
send the full final updated EA
- Assistant
- User
'PositionSelectByIndex' - undeclared identifier aaa.mq5 244 12 'i' - some operator expected aaa.mq5 244 34 'PositionSelectByIndex' - undeclared identifier aaa.mq5 261 12 'i' - some operator expected aaa.mq5 261 34
- Assistant
- User
send the full EA with these fixes applied.
- Assistant
- User
why no position open?
- Assistant
- User
DE30.p,M1: history cache allocated for 322944 bars and contains 303359 bars from 2024.01.02 09:00 to 2025.04.30 23:00 IN 0 07:46:49.171 Core 1 DE30.p,M1: history begins from 2024.01.02 09:00 DE 0 07:46:49.171 Core 1 DE30.p : real ticks begin from 2025.05.02 00:00:00 DP 0 07:46:49.171 Core 1 final balance 10000.00 USD JD 0 07:46:49.171 Core 1 DE30.p,M15: 550679 ticks, 1095 bars generated. Environment synchronized in 0:00:00.024. Test passed in 0:00:00.359. DH 0 07:46:49.171 Core 1 DE30.p,M15: total time from login to stop testing 0:00:00.383 (including 0:00:00.024 for history data synchronization) ME 0 07:46:49.171 Core 1 87 Mb memory used including 20 Mb of history data, 64 Mb of tick data
- Assistant
- User
yes EA with all these debugging prints added
- Assistant
- User
- Assistant
- User
fix : Your breakout condition is likely too strict (strict inequality). Price equals breakout low but price < low fails. EMA filter making buy signals impossible (price below EMA).
- Assistant
- User
prepare a full EA version with these fixes included.
- Assistant
- User
still nothing
- Assistant
- User
create a new ea from scratch
- Assistant
- User
Max drawdown percent , equity based, must close all positions stop trading for the day,
- Assistant
- User
full updated version
- Assistant