1

Hi I have EA with code structure like this,

void OnTick()  
{
   resetCounterVar(); //there's for loop
   CloseOrders(); //there's for loop
   UpdateAllOpenOrders(); //there's for loop
   SetSLTP(); //there's for loop    
   CheckPendOrder(); //there's for loop
   if(IsNewCandle() && pendingOrderCount<MaxPendingOrder) 
      OpenOrders();   
  }

I want to make the for loop instead for every function into like this,

for(int i = OrdersTotal() - 1; i >= 0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS)                 &&
         OrderSymbol() == Symbol()
        {
         resetCounterVar();
         CloseOrders();
         UpdateAllOpenOrders();
         SetSLTP();
         CheckPendOrder();
if(IsNewCandle() && pendingOrderCount<MaxPendingOrder)
  OpenOrders();

What I want to ask does the second code structure more efficient then the first one?

  • Efficiency is relative, add a Millisecond Timer before each piece of code to check which runs faster, simple! – PaulB Oct 05 '22 at 13:24

0 Answers0