error 138 in backtesting, please take a look into this code

 

Hello Guys,

I am getting error 138 (requote) only in backtesting it looks to be fine in demo acount.

any clue?

here is my code:

#include <stdlib.mqh>
int ID = 1111;
bool ShortIsOpen;
bool LongIsOpen;
int ticket;
extern double Lots = 0.1;

int slippage = 3;
int order;
int to;

int init(){
   ShortIsOpen = false;
   LongIsOpen = false;
   order = 0;
   return(0);
  }

int deinit(){
      return(0);
  }

int start(){
      //housekeeping
      if(!LongIsOpen && !ShortIsOpen)
            ticket=-1;  
           
      //status 
      Comment(
      " ShortIsOpen=",ShortIsOpen,
      " LongIsOpen=",LongIsOpen,
      " TriggerShort()=",TriggerShort(),
      " TriggerLong()=", TriggerLong(),
      " CloseShort()=",CloseShort(),
      " CloseLong()=",CloseLong(),
      " ticket=",ticket,
      " order=",order,
      " TimeCurrent()-to=",TimeCurrent()-to,
      );
      
      //closing orders
      if(ShortIsOpen || LongIsOpen){
       if(CloseShort()){
                        OrderClose(ticket,Lots,Ask,slippage,Black);
                        ShortIsOpen=false;
                        to = 0;
                        order--;
                        ticket=-1;
                        Print("short closed");
                     }
      if(CloseLong()){
                        OrderClose(ticket,Lots,Ask,slippage,Black);
                        LongIsOpen=false;
                        to = 0;
                        order--;
                        ticket=-1;
                        Print("long closed");
                     }
       }
      // end of closing 
      
      //Open Orders
      if(!ShortIsOpen && !LongIsOpen){
      if(TriggerShort()){
                  ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,slippage,0,0,"SMA",ID,0,Red);
                  if(ticket>0){
                     ShortIsOpen=true;
                     to=TimeCurrent();
                     order++;
                     Print("short triggered");
                  }else  Print("!ShortIsOpen && TriggerShort() OrderSend failed with error #:\t",GetLastError());
                  }
     
      if(TriggerLong()){
                  ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,0,0,"SMA",ID,0,Green);
                  if(ticket>0){
                     LongIsOpen = true;
                     to = TimeCurrent();
                     order++;
                     Print("long triggered");
                  }else  Print("!LongIsOpen && TriggerLong() OrderSend failed with error #:\t",GetLastError());
               }
               }
   return(0);
   }

bool TriggerShort(){
   bool rslt = false;
   //if trigger short logic is true, rslt = true
   return (!ShortIsOpen && true);
  
}
bool TriggerLong(){
   bool rslt = false;
   // if trigger long logic is true, rslt = true
   return (!LongIsOpen && rslt);
}
bool CloseShort(){ 
   bool rslt = false;
   // if close short logic is true, rslt= true
   return (ShortIsOpen && rslt);
}


bool CloseLong(){ 
   bool rslt =false
   // if close long logic is true, rslt = true
   return (LongIsOpen && rslt);
}



 
Here. More then likely, you had the wrong price.
 
ciremql4:

Hello Guys,

I am getting error 138 (requote) only in backtesting it looks to be fine in demo acount.

I see where your problem is . . .

Where are you getting this error ? what part of your code is generating it ? if you had checked return values from ALL order transactions you would have a good idea of what was generating this error . .

 
Not adjusting slippage for 5 digit broker.
 
thanx WHRoeder! thats precise the solution!
 
whroeder1:
Not adjusting slippage for 5 digit broker.

Thanks also.  Easy fix.

Reason: