I have been experimenting with different ways to send my orders and handle the errors, here is what I have come up with so far....
It seems to work pretty well but I wanted to get a few extra sets of eyes on to see if there are any obvious improvements that can be made before I send it off to a real programmer ( who will probably read this post ) for efficency purposes.
It seems to work pretty well but I wanted to get a few extra sets of eyes on to see if there are any obvious improvements that can be made before I send it off to a real programmer ( who will probably read this post ) for efficency purposes.
PHP Code
void GoLongOne(){ int lticket=0; int err=0; int c = 0; int Attempts = 100; for(c = Attempts ; c >= 0; c--){ RefreshRates(); lticket=OrderSend(Symbol(),OP_BUY,LongOneLots,Ask,0,Ask-HardSL*Point,Ask+TakeProfit*Point,"Long Level One",LongOneMagic,0,Lime); if (lticket > 0) break; err=GetLastError(); if(err==0 || err==2 || err==4 ||err==6 || err==8 || err==9 || err==64 || err==128 || err==132 || err==133 || err==137 || err==139 || err==141 || err==146){ //Sleep and retry errors Sleep(10); continue; } if(err==135 || err==136 || err== 138){ // price change errors Print ("..................Invalid Price Long Order.............."); if(TakeSnapShots==true){WindowScreenShot("S_REQUOTE_"+Month()+"_D"+Day()+"_H"+Hour()+"_M"+Minute()+"_S"+Seconds()+".gif",1440,900);} start();//restart and make sure that new price meets our entry criteria break; } else{ // other errors Print(".......................Error Code= ", err); break; } } }
Keep it simple stoopid....