Need to double check some code with Slawa ?

 
Hi Slawa,

Thank you for pointing out a vital error in my code. I have now revised the code and fixed error i think. Would you be able to have a look at it for me to see if you can see any other error, problem or bug?

Basiacally code says if we SendOrder() and get no error we wait only 200 milliseconds, then code goes straight to closing rule section of code to see if should close order.

If after OrderSend we get "price change" or "re-quote" error we only wait 200 milliseconds before re-try, we dont re-try with zero delay, as this could overload broker server with too frequent requests, and thus reduce their available liquidity credit line with bank too quickly.

If after OrderSend we get some "other error" like "busy server" or "broken connection" (excluding a price change or re-quote error) we wait only 5 seconds.

Does this seem ok to you?

Here is code I'm now using, can you see any other bug?

Thank you Slawa.


int start()   {

while ( IsStopped()==false )   {

If ( Bid > High[1] )   {
       
OrderSend(Symbol(),OP_BUY,LotsA,Ask,0,0,0,"",13,0,Aqua); 
        
Error=GetLastError();
       
Print("Error opening Order A : ", Error );   //   0 = No Error
       
if (Error==0 || Error==135 || Error==138) Sleep(200); else Sleep(5000);       				
			
RefreshRates();              
     
    }
  }
}



Thank you so much once again.

 
If Error==0 You will send next order. Why?
 
If Error==0 You will send next order. Why?


Because next order is a close order. We send an order to buy and then wait 200 milliseconds, then check to see if we should close order.

Does this seem ok with you.

Thanks Slawa. Always much appreciated.

Regards

Rod
 
IMHO there is conceptually incorrect. Order must exist much more than 200 milliseconds. Or You need for more accurate signal to entry
Reason: