Build 226 - Order stack and iTime() issues

 
This is where the problem occurs for iTime()..it used to work just fine.

   chartTime      = iTime(currPair,PERIOD_M1,0);


Here's the code stub where the Open Order stack is disappearing...

   // ---------------------------------------------------------
   // Determine if there are active Buy or Sell orders to close
   // ---------------------------------------------------------
   if(chartMin >= _trdCloseMin)
   {
      orderCount=OrdersTotal();
      for(x=orderCount+1; x>=0; x--)
      {
         orderFound=OrderSelect(x,SELECT_BY_POS,MODE_TRADES);
         
         if(orderFound
         && OrderSymbol() == currPair
         && OrderMagicNumber() == _magicNbr)
         {  
            Print("Closing orders");
            
            if(OrderType() == OP_BUY)
            {  OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid,d), _slippage*dmult*2); }
            
            if(OrderType() == OP_SELL)
            {  OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask,d), _slippage*dmult*2); }
         }
      }
      return;
   }

Curious if anyone else has experienced these problems in Build 226 Strategy Tester:

1) The open order stack just disappears

2) iTime() returns unpredictable data


Any thoughts would be greatly appreciated.
 
justhooked01:

Curious if anyone else has experienced these problems in Build 226 Strategy Tester:

1) The open order stack just disappears

I don't know what u mean by 'disappears'... Your code has a bug though, it should be:

      orderCount=OrdersTotal();
      for(x=orderCount-1; x>=0; x--)

2) iTime() returns unpredictable data

What is the value of 'currPair'? Are u sure it's the currently tested symbol? (u can't access iTime() data for other symbols in the Tester).

 
gordon:

I don't know what u mean by 'disappears'... Your code has a bug though, it should be:

What is the value of 'currPair'? Are u sure it's the currently tested symbol? (u can't access iTime() data for other symbols in the Tester).


Gordon,


The orderCount+1 vs. orderCount-1 was something I tried and didn't revert back before posting. As coded it's really not a bug, just an inefficiency. Anyway, the results are the same: Not all currently active orders are found in the loop.


This same logic loop is running successfully in live EAs, or it was before this weekend, and has never given me problems. Variable currPair is populated by function Symbol() at EA initialization. It may be a little old school, but in most of the languages I've dealt with over the last 30 year accessing memory is typically faster than a function call. Maybe that's not true in this case...


It's kind of interesting because I put this EA up on a demo account last night with a live data feed and things are working as expected. The problem seems to only exist in Strategy Tester, any thoughts?

 
justhooked01:
[...] Not all currently active orders are found in the loop [...] The problem seems to only exist in Strategy Tester, any thoughts?

I am pretty sure it's a problem with your code (although I can't find the problem in your sample, check the rest of your code or post it here)... This part of the platform is proven to work reliably.

2 comments:

 
gordon:

I am pretty sure it's a problem with your code (although I can't find the problem in your sample, check the rest of your code or post it here)... This part of the platform is proven to work reliably.

2 comments:


Both great suggestions, thank you. I will be reading these tonight.


Now for the fun part. The problem has disappeared. Thinking back I do remember having issues with Strategy Tester on another Sunday night and when I came back to it on Monday night everything was hunky dory. Didn't change anything and never did figure out what it may have been. That time I didn't post anything on the Forum because I wanted to dig in a little first. This time I applied the service pack for Build 226 on Sunday afternoon and just assumed the issue was related to the new build. I guess the old adage: never assume it makes an @$$ out of u and me applies in this case (at least it seems to apply to me...).


Sorry for wasting your time and thank you again for the suggested readings. Have a great evening.

Reason: