EA opened 100 trades instead of only one

 

today when the market opened I found that the EA , opened 100 trades instead of only 1 , unfortunately 22 lots instead of 0.22 , it was very dangerous and caused me high loss closing the trades (unfortunately I kept 3 not closed and they closed with TP :(  

, I have no problems with the setting , do any one faced this bug before , , what I can do in order to avoid this  in the future with any other EAs , advise how can I limit trades numbers if this bug happened again ? 

, the developer of EA deleted it from market (Goodmorning EA ) thanks

 
Amgad Megahed:

today when the market opened I found that the EA , opened 100 trades instead of only 1 , unfortunately 22 lots instead of 0.22 , it was very dangerous and caused me high loss closing the trades (unfortunately I kept 3 not closed and they closed with TP :(  

, I have no problems with the setting , do any one faced this bug before , , what I can do in order to avoid this  in the future with any other EAs , advise how can I limit trades numbers if this bug happened again ? 

, the developer of EA deleted it from market (Goodmorning EA ) thanks

The bug is in the EA. Without source code, it can not be fixed.

 

With my experience, when the market open at beginning of week. Spread is so big, it's seem match both Buy and Sell conditionals.

So, I improved my code by:

1. Do not trade 30 mins after open time of week, 30 mins before close time of week

2. Always use count total Buy, total Sell for each Symbol, make sure EA never entry more than I expected.

3. In MT5, I refer use onTimmer() instead of onTick()

 
Enrique Dangeroux #:

The bug is in the EA. Without source code, it can not be fixed.

Thanks Enrique , that is what I thought , do you have any sugestion to limit number if same bug happened ? thanks 

 
Pham Khanh Duy #:

With my experience, when the market open at beginning of week. Spread is so big, it's seem match both Buy and Sell conditionals.

So, I improved my code by:

1. Do not trade 30 mins after open time of week, 30 mins before close time of week

2. Always use count total Buy, total Sell for each Symbol, make sure EA never entry more than I expected.

3. In MT5, I refer use onTimmer() instead of onTick()

thanks Pham , unfortunately it is not my EA , I do not have the source code , fortunately it did not blown up me this time . 

the confusing that I am using since long time , it is first time to cuase this , and I setted it up on many charts , all with fixed lot and they were fine except the only one with Dynamic lot went wrong . 

 
Pham Khanh Duy # :

With my experience, when the market open at beginning of week. Spread is so big, it's seem match both Buy and Sell conditionals.

So, I improved my code by:

1. Do not trade 30 mins after open time of week, 30 mins before close time of week

2. Always use count total Buy, total Sell for each Symbol , make sure EA never entry more than I expected.

3. In MT5, I refer use onTimmer() instead of onTick()

This is not fool-proof

Forum on trading, automated trading systems and testing trading strategies

Great and terrible MT4 forever (or how to correctly develop a transition strategy)

fxsaber , 2021.05.05 02:04

 // Демонстрация открытия дубля позиции в MT5.

#include <Trade\Trade.mqh>

void OnStart ()
{
  CTrade Trade;
  
   while (! IsStopped () && ( PositionsTotal () <= 1 )) // Закончим, когда появится более одной позиции.
     if ( PositionsTotal () == 1 )
      Trade.PositionClose( PositionGetTicket ( 0 )); // Если есть позиция - закрываем.
     else if (! OrdersTotal ())
      Trade.Buy( 0.01 ); // Если нет позиции и ордера - открываем позицию.
}

Run this code on an empty demo account and see two positions open in a few seconds.


The same logic on MT4 looks like this.

 void OnStart ()
{
   while (! IsStopped () && ( OrdersTotal () <= 1 )) // Закончим, когда появится более одной позиции.
     if ( OrderSelect ( 0 , SELECT_BY_POS))
      OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0 ) // Если есть позиция - закрываем.
     else
       OrderSend ( _Symbol , OP_BUY, 0.01 , Ask, 0 , 0 , 0 ) // Если нет позиции и ордера - открываем позицию.
}

It is clear that such a code on MT4 will not cause a double position. But not on MT5.


Reason: