Does ErrorLevel work in LibOrderReliable_V1_1_2.mq4?

 

1. ErrorLevel is declared as a variable static int ErrorLevel = 3;

2. ErrorLevel is used several times, typically if (ErrorLevel > 1) <=== remember, it was set to 3

3. And finally, near the bottom of the code, is a function

void OrderReliableSetErrorLevel(int level)
{
ErrorLevel = level;
}

...but this function OrderReliableSetErrorLevel is never called!

So, I'm wondering if modifying the original code would work better.

ORIGINAL CODE
=============
int cnt = 0;
while(!IsTradeAllowed() && cnt < retry_attempts)
{
OrderReliable_SleepRandomTime(sleep_time, sleep_maximum);
cnt++;
}

if (!IsTradeAllowed())
{
if (ErrorLevel > 1)
OrderReliablePrint("error: no operation possible because IsTradeAllowed()==false, even after retries.");
hold_err = ERR_TRADE_CONTEXT_BUSY;
return(-1);
}

MODIFIED CODE
=============
int cnt = 0;
while(!IsTradeAllowed() && cnt < retry_attempts)
{
OrderReliable_SleepRandomTime(sleep_time, sleep_maximum);
cnt++;
}

if (!IsTradeAllowed())
{
OrderReliablePrint("error: no operation possible because IsTradeAllowed()==false, even after retries.");
hold_err = ERR_TRADE_CONTEXT_BUSY;
return(-1);
}

 

static means it will be initialized one time...

int start(){

   static int count1 = 0; // initialized once

          int count2 = 0; // initialized every tick


   count1++;

   count2++;

   Comment("\n Count1 = " + count1 +"\n"+ 

           "\n Count2 = " + count2 +"\n");

   return(0);

}
 
phy wrote >>

static means it will be initialized one time...

phy
wrote
>>

static means it will be initialized one time...

Thank you, but I'm sorry I don't understand your reply. Yes, a static int is initialized one time -- but as best as I can tell, the code never changes the value of ErrorLevel at any later time. That leaves me with:

- The function OrderReliableSetErrorLevel which is never called and therefore might be removed from the code

- A never-changing value of ErrorLevel = 3 which will always cause OrderReliablePrint to execute

...so, why have the lines of code such as: if (ErrorLevel > 1)

 

Oh well...

LibOrderReliable_V1_1_3.mq4 is out there too

 
phy wrote >>

Oh well...

LibOrderReliable_V1_1_3.mq4 is out there too

Yes, but the newer version V1_1_3 (when searched with Edit > Find > ErrorLevel) seems to have the same useless code where...

- int ErrorLevel = 3

- The function OrderReliableSetErrorLevel is never called and therefore might be removed from the code

- A never-changing value of ErrorLevel = 3 which will always cause OrderReliablePrint to execute

...so, why have the lines of code such as: if (ErrorLevel > 1)

So far, I think:

- my analysis of the code is correct

- the function OrderReliableSetErrorLevel is never used and might be removed without consequence

- there is no use for a line of code such as if(ErrorLevel > 1) ...because ErrorLevel will always be 3.

Of course, I've been wrong before (well, once actually :-). Anybody want to look at this? Thank you.

 
chaffinsjc wrote >>

Yes, but the newer version V1_1_3 (when searched with Edit > Find > ErrorLevel) seems to have the same useless code where...

- int ErrorLevel = 3

- The function OrderReliableSetErrorLevel is never called and therefore might be removed from the code

- A never-changing value of ErrorLevel = 3 which will always cause OrderReliablePrint to execute

...so, why have the lines of code such as: if (ErrorLevel > 1)

So far, I think:

- my analysis of the code is correct

- the function OrderReliableSetErrorLevel is never used and might be removed without consequence

- there is no use for a line of code such as if(ErrorLevel > 1) ...because ErrorLevel will always be 3.

Of course, I've been wrong before (well, once actually :-). Anybody want to look at this? Thank you.

Where do we go from here? Nobody seems to notice that the proposed answers may indeed be wrong.

How do I "advertise" that this is an UNSOLVED PROBLEM and has NOT REACHED RESOLUTION?

 
chaffinsjc:

Where do we go from here? Nobody seems to notice that the proposed answers may indeed be wrong.

How do I "advertise" that this is an UNSOLVED PROBLEM and has NOT REACHED RESOLUTION?

OrderReliableSetErrorLevel() should be used from your code, to set the errorlevel according to your preference...

anyway meanwhile I have changed v1.1.3, adding support for MarketInfo (as in v1.1.1). I have attached the new version...

 

OrderSendReliable changed for pending order on ERR_INVALID_STOPS:
- avoid sporadical infinite loops (log entry: OrderSend error 130)

p.s. I had to upload LibOrderReliable_v1_1_5.mq4 twice, but the system renamed the second version, so please don't forget to rename it back (to LibOrderReliable_v1_1_5.mq4) after download

Reason: