whats wrong

 

Hello


when i like to modify the order the code runs multible in the ea


if (Hour() == (Start1 - 2) && Minute() >= 0){
done = 0; // set done to 0 2 hours before
}


if (done == 0){ // if done is 0 modify order

for (int i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderComment() == Text && Hour() == (Start1 - 1) && Minute() >= 55 ){

if( OrderType() == OP_BUY && OrderProfit() != 0 ){ //no buy order
Ticket = OrderModify(OrderTicket(),OrderOpenPrice(),TL_Long,OrderTakeProfit(),OrderExpiration(),Blue);

}


if( OrderType() == OP_SELL && OrderProfit() != 0 ){ //no sell order
Ticket = OrderModify(OrderTicket(),OrderOpenPrice(),TL_Sell,OrderTakeProfit(),OrderExpiration(),Green);

}
done = 1; // set done to 1
}



}
Sleep(10000);

}



anybody has any idea?


kind regards

 

You have to check is old OrderStopLoss() equal TL_Long or not.

 
Roger:

You have to check is old OrderStopLoss() equal TL_Long or not.

this isnt the problem bcs the order modify are working right on time.

but in the 5 minutes from 6:55 to 7:00 its run all 10 seconds

 

amando wrote >>

anybody has any idea?

Yes. Put in more Print() statements so nobody has to do any guessing.

 
is Done static or external?
 

done is static integer


i set it to 0 2 hours before time

 
if (Hour() == (Start1 - 2) && Minute() >= 0){ 
  done = 0; // set done to 0 2 hours before
}

You set it zero, modify order, set to one.

next tick repeat

Minute()>=0 is always true

Also this won't work in the tester. Hour/Minute() is current server time where as you want the time of the tick TimeHour(CurTime())

Reason: