Problem with updating a value
??????????
Question does not fit the code shown.
if ( iClose(NULL,0,23)>iClose(NULL,0,12) ) then integer =1
Then:
if ( iClose(NULL,0,2)< iClose(NULL,0,1)) res=OP_BUY;
if ( iClose(NULL,0,2)> iClose(NULL,0,1) res=OP_SELL;
OR
if ( iClose(NULL,0,23)<iClose(NULL,0,12) ) then integer =2
Then:
if ( iClose(NULL,0,3)< iClose(NULL,0,2)) res=OP_BUY;
if ( iClose(NULL,0,3)> iClose(NULL,0,2) res=OP_SELL;
//+------------------------------------------------------------------+ //| function of issuing trade siglnal | //+------------------------------------------------------------------+ int yourFunction() { int res ; if ( iClose(NULL,0,23)>iClose(NULL,0,12) ) {//True if ( iClose(NULL,0,2) < iClose(NULL,0,1) ) res=OP_BUY; else res=OP_SELL; } else {//False if ( iClose(NULL,0,3) < iClose(NULL,0,2) ) res=OP_BUY; else res=OP_SELL; } return (res); }
I try to do a random choice between two values, as shown below. The problem is that sometimes the value is not updated timely and the new value instead of using new uses old and new open order is wrong. Interestingly, then is updated, but it is too late. Where could be a problem? I trade on offline chart with no problem, but may be something is wrong?