Testing Multiple Symbols Execution fails after a few days.

Chris Stols
56

Hi There;


I've written a system on EA that hopefully executes multiple symbols concurrently.

I=t works perfectly per individual instrument. just need to find a way to execute it properly on multiple symbols.


The error starts at ticket 50+ for 2 instruments on the backend.

meaning i'm able to generate halve of the month's profits only.


as far as i can tell it does not make sense that it's a logic error; why would it yield up to 50 tickets in execution.

the journal yields no error.


My code looks roughly as follows:


#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\PositionInfo.mqh>

CTrade m_trade;
CSymbolInfo    m_symbol;
CPositionInfo  m_position;

int MagicNumber=777;
string SymbolsToRun[] = {"AUDCHF", "AUDJPY", "XAUUSD"};

int OnInit()
  {
//--- create timer
   EventSetTimer(1);

   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
   EventKillTimer();
  }

class PositionStructure
  {
public:
         // lots of variables.

          PositionStructure()
     {

     }
  };

class PositionForSymbolStructureBase : public PositionStructure
  {
public:
        // More variables.

             PositionForSymbolStructureBase()
     {

     }
  };

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class PositionForSymbol_XAUUSD : public PositionForSymbolStructureBase
  {
public:
                     PositionForSymbol_XAUUSD()
     {
      ProductName = "XAUUSD"; // Symbol Name.
      RecoveryPipSize = 6; // This value is in pips.
      StartProfits = 1.5; // This value is in Dollars.
      BaseLotSize = 1;
     }
  };

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class PositionForSymbol_AUDCAD : public PositionForSymbolStructureBase
  {
public:
                     PositionForSymbol_AUDCAD()
     {
      ProductName = "AUDCAD"; // Symbol Name.
      RecoveryPipSize = 0.005; // This value is in pips.
      StartProfits = 0.40; // This value is in Dollars.
      BaseLotSize = 10;
     }
  };



PositionForSymbol_XAUUSD m_PositionForInstrument; // Initializer; gets reset per symbol as needed in runtime.
//+---------------------------------------------------------------------+
//| Initialize class object - gets reset per instrument per tick value. |                                                                 |
//+---------------------------------------------------------------------+
PositionForSymbol_XAUUSD m_PositionForInstrument_XAUUSD;
PositionForSymbol_AUDCAD m_PositionForInstrument_AUDCAD;


void OnTimer()
  {
   ExecuteRunTime();
  }

void ExecuteRunTime()
  {
   for(int i=0; i < SymbolsToRun.Size(); ++i)
     {
      // Set our class instance to work with appropriately.
      SetSymbol(SymbolsToRun[i]);

      PositionSelect(SymbolsToRun[i]);
      double _dBidValue = SymbolInfoDouble(m_PositionForInstrument.ProductName,SYMBOL_BID);
      double _dAskValue = SymbolInfoDouble(m_PositionForInstrument.ProductName,SYMBOL_ASK);
      
      // Do some actions pertaining to buy/sell
     }
  }