MultiSymbol Expert Advisor in MQL4 coding

To add comments, please log in or register
Gbenga Ayodele
600
Gbenga Ayodele  

In order to maximize trading opportunity, i entered into multi pair EA coding community. The problem in it so far is dealing with chart that are not opened in the chart window, refreshing the chart to get latest tick and most importantly getting the EA to read accurate tick data when OnTick() is executed.


 Most Common Error(s) are:

       1. 2019.12.16 07:57:50.901 '644861': order sell 0.01 ..SYMBOL.. opening at 25.468 sl: 0.000 tp: 0.000 failed [Trade is disabled] ..................................................... (journal)

       2.  2019.12.16 07:35:20.259 EA ..SYMBOL..,..PERIOD..: Abnormal termination....................................................................................................................(Expert)

       3. 2019.12.16 07:35:12.756 EA ..SYMBOL..,..PERIOD..: shutdown by timeout.....................................................................................................................(Expert)

William Roeder does failed [Trade is disabled] error allows for continuous operation of the EA in other Symbols that are active? 

                          I noticed that after this error in the journal, trading for other symbols is not executed until i re-attached the multi Symbol EA.

void OnTick()
  {


   for(int k =SymbolsTotal(false); k>=0; k--)
     {
     string SYMB = SymbolName(k,0);
            
             if(!IsTradeAllowed(SYMB,TimeCurrent()))continue; // for ignoring trade is disabled for a particular currency pair in the basket..
          //................to do here.....................



           //.............................................,
       }

    } 

that line of code does not solve the error 

Please How can i resolve this errors



William Roeder
William Roeder
  • www.mql5.com
Trader's profile
Reza nasimi
444
Reza nasimi  
Gbenga Ayodele:

In order to maximize trading opportunity, i entered into multi pair EA coding community. The problem in it so far is dealing with chart that are not opened in the chart window, refreshing the chart to get latest tick and most importantly getting the EA to read accurate tick data when OnTick() is executed.


Are you trying to use it on the tester?

If so, you can't.

MT4 tester is not supporting multi-Symbol EAs.


Also make sure you are using MODE_ASK and MODE_BID using the MarketInfo(), and not Ask and Bid and also don't forget about MODE_POINT.

you need to care about what you see in this page to make sure everything you are use is belonging to the selected Symbol. 


The OnTick function is not spouse to be called for each symbol. it will be called based on the chart which it is attached to. 

Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL4 Reference
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
A zero value of MODE_STOPLEVEL means either absence of any restrictions on the minimal distance for Stop Loss/Take Profit or the fact that a trade server utilizes some external mechanisms for dynamic level control, which cannot be translated in the client terminal. In the second case, GetLastError() can return error 130, because MODE_STOPLEVEL...
Gbenga Ayodele
600
Gbenga Ayodele  

i Know Multi-symbol EA won't work on tester. It is my real account i'm working on.

 The reason for this implementation is that real trade signal only comes maybe once a week after so many filter to make sure i am getting realistic signal.

consider trading (one pair-one time frame) that generate signal after long time. this will not make profitable  outcome but when there are so many symbols with so many timeframe,

the expert would like pull up to 20 to 30 trades in all symbols per day on the minimum. Thus why i need to get it working. The EA is doing great with 99.9% accuracy except for this buffer/ stack overflow error and hanging of my core i5 2.5GHZ processor PC with only this EA running on it.Sometime its temp get to 63 degree......

Gbenga Ayodele
600
Gbenga Ayodele  


this is the journal image.

Gbenga Ayodele
600
Gbenga Ayodele  
    if(GetLastError()==133)
        {

         ResetLastError();
         Sleep(5000);
         RefreshRates();
        }

I put this line on top of the code and it removed the [Trade is Disabled] error

everything now works fine without any error

thank you reza nasimi for you help. 


It now look like this:

void OnTick()
  {


   for(int k =SymbolsTotal(false); k>=0; k--)
     {
     string SYMB = SymbolName(k,0);
            
//...........................................
    if(GetLastError()==133)
        {
         ResetLastError();
         Sleep(5000);
         RefreshRates();
        }
//...........................................
             if(!IsTradeAllowed(SYMB,TimeCurrent()))continue; // for ignoring trade is disabled for a particular currency pair in the basket..
      //................to do here.....................



     //.............................................,
      }

  } 
To add comments, please log in or register