Author of the idea: Vladimir Khlystov, author of the MQL5 code: barabashkakvn.
The Nevalyashka Breakdown Level EA operates on a straightforward trading strategy: it identifies breakouts of the High/Low within a defined time period. The EA employs the Nevalyashka strategy, combined with a martingale approach, to boost the lot size when recovering from losing trades.
This EA pinpoints the High and Low prices during your specified timeframe, set between Time start and Time end:

If the price surpasses the High during this period, a BUY position is triggered. Conversely, if the price dips below the Low, a SELL position is initiated. The Stop Loss is positioned at the opposite boundary of the period—at the Low price for BUY trades and at the High price for SELL trades. The Take Profit is calculated based on the range of the control period.
When the Use time close setting is enabled, the Time close parameter activates, determining when to close all positions.
Only hours and minutes are considered for the Time start, Time end, and Time close parameters.
Stop Loss closure is monitored in OnTradeTransaction.
When a DEAL_ENTRY_OUT event occurs, check the comment section of the trade. If the comment contains "sl", it indicates a Stop Loss closure:
if(deal_symbol==m_symbol.Name() && deal_magic==m_magic) if(deal_entry==DEAL_ENTRY_OUT) { MqlDateTime str1; TimeToStruct(TimeCurrent(),str1); //--- this might be a Take Profit closure if(StringFind(deal_comment,"tp",0)!=-1 || deal_profit>=0.0) { TradeDey=str1.day; return; } //--- this might be a Stop Loss closure if(StringFind(deal_comment,"sl",0)!=-1) { if(TradeDey!=str1.day) { Print("A StopLoss closure has been detected!"); double loss=MathAbs(deal_profit/m_symbol.TickValue()/deal_volume); if(deal_type==DEAL_TYPE_SELL) // the buy position is closed { double SL=m_symbol.Bid()+loss*m_symbol.Point(); double TP=m_symbol.Bid()-loss*m_symbol.Point(); double Lot=LotCheck(deal_volume*InpK_martin); if(Lot==0.0) return; OpenSell(SL,TP,Lot,"Nevalyashka"); if(deal_type==DEAL_TYPE_BUY) // the sell position is closed { double SL=m_symbol.Ask()-loss*m_symbol.Point(); double TP=m_symbol.Ask()+loss*m_symbol.Point(); double Lot=LotCheck(deal_volume*InpK_martin); if(Lot==0.0) return; OpenBuy(SL,TP,Lot,"Nevalyashka"); } return; } }
You’ll want to open a position opposite to the one that was closed (if you closed a SELL, you’ll open a BUY, and vice versa), with an increased lot size adjusted by K. martin. If the position closed with a profit, the EA will wait for the next period to start at Time end and repeat the process.
No loss parameter refers to breakeven; once half of the position’s profit is achieved, the Stop Loss is adjusted to the entry price.
Here’s a quick example if you’re testing on EURUSD, M30:

Related Posts
- Leveraging MQL5 Wizard: Crafting Trade Signals with Meeting Lines and Stochastic
- Mastering Bullish and Bearish Harami Patterns with Stochastic in MT5
- Mastering Trading Signals with MQL5 Wizard: Bullish and Bearish Engulfing Strategies
- Creating Powerful Trade Signals with MQL5 Wizard: Bullish and Bearish Engulfing Patterns + RSI
- Creating an Expert Advisor for Dark Cloud Cover and Piercing Line Patterns with CCI Confirmation