Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Nevalyashka_BreakdownLevel - MetaTrader 5 Expert - MT4/MT5 Resources

author EAcpu | 2 reads | 0 comments |

Nevalyashka_BreakdownLevel - expert for MetaTrader 5

Nevalyashka_BreakdownLevel - expert for MetaTrader 5

The author of the ideaVladimir Khristov , the author of the MQL5 codeBarabashkakon .

Trading Strategy: Break highs/lows over selected time intervals. To recover losing positions, the EA uses the "Nevalyashka" strategy and the martingale technique to increase the lot size.

The EA calculates the highest and lowest prices within the specified time interval " Time Start " to " Time End " :

Nevalyashka_BreakdownLevel - expert for MetaTrader 5

If the price exceeds the highest point of the period, a buy position is opened. If the price is below the lowest price, a sell position is opened. Stop losses are set at the opposite boundaries of the cycle, i.e. low prices for buy positions and high prices for sell positions. Take profit is set based on the height of the control period.

If " Use time to close " is set to true, the " time to close " parameter (time to close all positions) will be activated.

Parameters only consider hours and minutes " time on " , " time on " and " time off ".

Stop-loss closing is monitored in OnTradeTransaction .

When "DEAL_ENTRY_OUT" (en: "Entry out") is found, check the comment field for that transaction. If the comment contains "sl" , it means the transaction was closed via StopLoss:

if (deal_symbol==m_symbol.Name() && deal_magic==m_magic)
if (transaction entry == DEAL_ENTRY_OUT )
          {
Mql datetime string 1;
BuildTime ( timecurrent (),str1);
//--- It is possible to close the position with take profit if ( string lookup (trade comment, "tp" , 0 )!=- 1 || trade profit >= 0.0 )
              {
              TradeDey=str1.day;
return ;
              }
//--- This may be stop loss closing
if ( String lookup (TransactionComments, "sil" , 0 )!=- 1 ) {
if (TradeDey!=str1.day)
                {
print ( "Stop loss detected!" );

Double loss = mathematical antibody (deal_profit/m_symbol.TickValue()/deal_volume);

if (Transaction Type == Transaction Type_Sell ) // The long position has been closed {
Double the SL=m_symbol. bid ()+loss*m_symbol. View ();
Double the TP=m_symbol. bid () - loss*m_symbol. View ();
Double Lot=LotCheck(deal_volume*InpK_martin);
if (many == 0.0 )
return ;
                    Open a position (stop loss, take profit, lot size, "Nevalyashka" );

                    }
if (Transaction Type == DEAL_TYPE_BUY ) // Sell position has been closed {
Double the SL=m_symbol. ask () - loss *m_symbol. View ();
Double the TP=m_symbol. ask ()+loss*m_symbol. View ();
Double Lot=LotCheck(deal_volume*InpK_martin);
if (many == 0.0 )
return ;
                    OpenBuy(stop position, take profit, lot size, "Nevalyashka" );
                    }
return ;
                }
              }
          }

Opening a position is the opposite of closing a position (if the transaction type is "DEAL_TYPE_SELL", the buying position is closed; "DEAL_TYPE_BUY" means the selling position is closed), increase the lot size multiplied by K·Martin . If the profit is positive when closing the position, the Expert Advisor will wait for the start time of the next period " Time End " and repeat the above process .

" No loss " The parameter indicates breakeven; when the position profit reaches half, the stop loss is moved to the position price.

Example of testing EURUSD, M30:

Nevalyashka_BreakdownLevel - expert for MetaTrader 5


Attachment download

📎 nevalyashka_breakdownlevel.mq5 (47.27 KB)

Source: MQL5 #18645

Verification code Refresh