Martingale algo not working. Is this a bug in MT5?

 
Found a new bug, I think?

I'm using 2 EAs, with 2 different Magic number on a same pair. Both EAs are using Martingale position sizing. 

However, when my EA1 had a loss, my EA2 is opened with a Martingale factor on the last closed position on my EA1.

Example: 

-EA1 trade 1 lot and hit my SL.
-EA2 opened a new position of 2 lots even though it is set to start at 0.5lot. 
-The position of 2 lots on my EA2 then hit my TP
-EA1 opens a new position with 1 lot, instead of 2 lots. 

The correct position sizing algo should be like this:

-EA1 opens 1 lot and hit SL
-EA2 opens 0.5 lot and hit TP
-EA1 opens 2 lots....

 
not a bug in mt5 
depends on your ea coding, it could happen
 
Martingale not good
 

Martingale, Hedging and Grid

The forum threads

  1. Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions)
  2. Definition: classical martingale, progressive dynamic growth martingale, progressive static growth martingale, anti martingale or inverse martingale
  3. Martingale, Hedging and Grid : MHG
  4. Featured Martingale EA to explore and expand, provided by a programmer 
  5. Does a safe Martingale exist ?
  6. Why people are still trying Martingale Systems?
  7. The Video - Trading The Martingale and Anti Martingale Strategies

CodeBase

  1. Angry Bird (Scalping) - expert for MetaTrader 4 - the settings and trades - look at this post.
  2. Three Typical Candles Martingale - expert for MetaTrader 5
  3. iRSI Martingale 10 Levels - expert for MetaTrader 5
  4. Grid Semiautomat Panel - expert for MetaTrader 5
  5. Grid Template EA - expert for MetaTrader 4
  6. VR---SETKA---3_v2 - expert for MetaTrader 5
  7. Grid - script for MetaTrader 5
  8. KNUX Martingale - expert for MetaTrader 4
  9. MacdPatternTraderAll0.01. Time+Martingale - expert for MetaTrader 4
  10. Pure_Martingale - expert for MetaTrader 4
  11. Trend_Catcher - expert for MetaTrader 5
  12. Ingrid Martingale - expert for MetaTrader 5
  13. MultiMartin - expert for MetaTrader 5
  14. N trades per set Martingale - expert for MetaTrader 4 
  15. Martingale Smart - expert for MetaTrader 4 
  16. Reversing Martingale EA - expert for MetaTrader 5
  17. VR Calculate Martingale Lite - indicator for MetaTrader 4
  18. VR Calculate Martingale Lite MT 5 - indicator for MetaTrader 5 
  19. Hoop master 2 - expert for MetaTrader 5
  20. Martingale EA - expert for MetaTrader 4
  21. Simple candle filter martingale EA - expert for MetaTrader 4
  22. RSI Martingale - expert for MetaTrader 5
  23. more here

The articles

============

 
Ng Zhen Sheng:
Found a new bug, I think?

I'm using 2 EAs, with 2 different Magic number on a same pair. Both EAs are using Martingale position sizing. 

However, when my EA1 had a loss, my EA2 is opened with a Martingale factor on the last closed position on my EA1.

Example: 

-EA1 trade 1 lot and hit my SL.
-EA2 opened a new position of 2 lots even though it is set to start at 0.5lot. 
-The position of 2 lots on my EA2 then hit my TP
-EA1 opens a new position with 1 lot, instead of 2 lots. 

The correct position sizing algo should be like this:

-EA1 opens 1 lot and hit SL
-EA2 opens 0.5 lot and hit TP
-EA1 opens 2 lots....

Martingale EAs are working by cycles, and the work of those kind of the EAs are related to the quality of data/quotes/datafeed and the time those EA attached on the chart to start trading.

So, yes, same martingale EAs on same pairs may perform in different way depends on when those two were attached to the chart, the quality of the data, MM used in those Martingale EAs and more.
You can check it in strategy tester by backtesting:

  • first backtesting - one performance;
  • backtest once again - it may be the other performance (more data/ticks were loaded between the first and second performance/backtest).

It is the nature of martingale systems.

------------------

So, if you want for your EAs to work in simultanious way - ask your coder to fix it (to improve it).
Because every coder knows about what I explained above on my this post (you are not a coder if you do not know it).

 
Sergey Golubev:
Martingale not good
I know right? Mine is actually a semi martingale with a factor of 1.5 and a R:R of 1.5. 

Still, a very risky strategy. 

But damn, just can't run it simultaneously. I no coder, just develop the system using an online EA builder. 
 
Ng Zhen Sheng:
I know right? Mine is actually a semi martingale with a factor of 1.5 and a R:R of 1.5. 

Still, a very risky strategy. 

But damn, just can't run it simultaneously. I no coder, just develop the system using an online EA builder. 

Fix your code

 
amando:

Fix your code

Any suggestions?


double MM_Size() //martingale / anti-martingale
  {
   double lots = MM_Martingale_Start;
   double MaxLot = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MAX);
   double MinLot = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN);
   ulong ticket = 0;
   if((ticket = LastHistoryTradeTicket(DEAL_ENTRY_OUT)) > 0)
     {
      if(HistoryDealGetDouble(ticket, DEAL_PROFIT) > 0 && !MM_Martingale_RestartProfit)
         lots = HistoryDealGetDouble(ticket, DEAL_VOLUME) * MM_Martingale_ProfitFactor;
      else if(HistoryDealGetDouble(ticket, DEAL_PROFIT) < 0 && !MM_Martingale_RestartLoss)
         lots = HistoryDealGetDouble(ticket, DEAL_VOLUME) * MM_Martingale_LossFactor;
      else if(HistoryDealGetDouble(ticket, DEAL_PROFIT) == 0)
         lots = HistoryDealGetDouble(ticket, DEAL_VOLUME);
     }
   if(ConsecutivePL(false, MM_Martingale_RestartLosses))
      lots = MM_Martingale_Start;
   if(ConsecutivePL(true, MM_Martingale_RestartProfits))
      lots = MM_Martingale_Start;
   if(lots > MaxLot) lots = MaxLot;
   if(lots < MinLot) lots = MinLot;
   return(lots);
  } 



 
There is no point in fixing code generated by any EA builder.
Reason: