Backtest bug with quantity of trades

 

Hi guys !

I am currently backtesting an EA and I have a problem with the quantity of trades . I can't seem to find a solution to that, anyone who know what it is ? :)

(SAME parameters, SAME product) ¨:  backtest for month of february (20 days)  : 23 trades.   Backtest for only february 18th (ONE DAY) : 65 trades.  How is that possible ?

Thanks to those who take the time to check my message out,

Cheers, 

R. 

 

Without code?

 
Gobelet: How is that possible ?
  1. Your code is broken. Previous trades are affecting future ones.
  2. There are no mindreaders here. No code, no possibility of help.
 

Hi, thanks for your answer,  I didn't know the code was necessary for the problem. The code is pretty ugly, though, hope you don't mind, I'm not good at coding.. :)

 EDIT : it doesn't seem to accept my code in the SRC zone, it does't upload it..   I will try again tonight and in the meantime I attach the file. 

Files:
 
  1. Gobelet: How is that possible ?
    int     ATRMin                =atrMin*iATR(NULL,0,15,0);
    int     ATRMax                =atrMax*iATR(NULL,0,15,0);
    These are constant. Depends only in the first tick of tester. If you want them to update you must assign values in start.
  2.       bool BUY=false;
          if(
          Check>0&&Check!=EMPTY_VALUE
          ){BUY=true;}
    
          bool BUY=  Check>0&&Check!=EMPTY_VALUE;
    
    Simplify when possible
  3.     for (int cnt = OrdersTotal(); cnt >= 0; cnt --){
          if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) {
        for (int cnt3 = OrdersTotal(); cnt3 >= 0; cnt3 --){
          if(OrderSelect(cnt3, SELECT_BY_POS, MODE_TRADES)) {
    
    Order positions are numbered [0 .. OrdersTotal() - 1] Your first iteration always fails.
  4.       OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
                OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);
                   OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);
    
    Check your return codes. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  5.       if(OrderSymbol()!=Symbol()) continue;
          pp = MarketInfo(OrderSymbol(), MODE_POINT); 
    
    You know you're using current chart pair. Why use a function call instead of the predefined double _Point - MQL4 Documentation Why at all (pp not used.)

  6.    if(Hour()>=MondayToFridayStartHour && Hour()<MondayToFridayEndHour)
    
    Doesn't allow trading over midnight e.g. start=1900 end=0700
 

Thank you so much for your help !  I will give a look at this tonight and see if it solve the problems, thank you for your time again !

Edit : for the point 3)  I don't really understand. Isn't the line " >= 0" there to make sure that the first iteration does not fail ?

        4)  you are right I should check them, I'm not used to check them yet, as I've not been coding for a long time and as I code for myself (as you can see by the lack of commentaries // next to the code ;) )

        6)  I don't intend to trade before StartHour and after EndHour, which is why I wrote that line. I think the positions will be kept overnight by the robot anyway.

 
Gobelet: t 3)  I don't really understand. Isn't the line " >= 0" there to make sure that the first iteration does not fail ?
Look at your other OrderSelect loops
 
for (int cnt = OrdersTotal()-1; cnt >= 0; cnt --)
 

Hello guys, 

 

I cleaned the code and changed everything you told me to change, it all works very good now. Thank you very much for your help and your time, it is very appreciated. Hope I can turn the favuor to you someday. 

 

R. 

Reason: