I hope I didn't delete anything I needed, otherwise the compiler would complain about the word else:
if(OrdersTotal()>0){// unnecessary line - if there are no orders, then the loop counter will be at zero and the loop will not be executed for(int i=OrdersTotal()-1;i>=0;i--){// go through all orders if (! OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){// ifno order is selected, then... if(OrderMagicNumber()!=MagicNumber) continue; //if the magic number is not ours, then proceed to another order if(OrderOpenTime()>=Time[0]) Torg=false; } // But what if the order is still selected from the list? } }
P.S.
The line that signals an error number when selecting an order should not have been removed for some reason - it sometimes happens that it blows up. In general, error handling is better used wherever it can occur.
drknn: if(OrdersTotal()>0){// unnecessary line - if there are no orders, the loop counter will be at zero and the loop will not be executed for(int i=OrdersTotal()-1;i>=0;i--){// go through all orders if (! OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){// ifno order is selected, then. if(OrderMagicNumber()!=MagicNumber) continue; //if the magic number is not ours, then proceed to another order if(OrderOpenTime()>=Time[0]) Torg=false; } // But what if the order is still selected from the list? } }
What if you try to check this loop in the script yourself? Well, just byprinting the result - what position the Torg variable takes in different cases. Do you think you can't do it yourself?
drknn: What if you try to check this loop in the script yourself? Well, just byprinting the result - what position the Torg variable takes in different cases. Do you think you can't do it yourself?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
bool Times=true;
if (OrdersTotal()>0){
for(int g=OrdersTotal()-1; g>=0; g--){
datetime t;
OrderSelect(g,SELECT_BY_POS);
if (OrderMagicNumber()!=MagicNumber){continue;}
if (t<OrderOpenTime() || g==OrdersTotal()-1) t=OrderOpenTime();
if (t>=Time[0]) Times=false;}}
is this correct?
bool Times=true;
datetime t=Time[1];
if (OrdersTotal()>0){
for(int g=OrdersTotal()-1; g>=0; g--){
OrderSelect(g,SELECT_BY_POS);
if (OrderMagicNumber()!=MagicNumber){continue;}
if (t<OrderOpenTime()) t=OrderOpenTime();
if (t>=Time[0]) Times=false;}}
is this correct?
No. You don't need to declare a variable inside the loop at each iteration.
I hope I didn't delete anything, otherwise the compiler would complain about the word else:
bool Torg=true;
if(OrdersTotal()>0){for(int i=OrdersTotal()-1;i>=0;i--){
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
if(OrderMagicNumber()!=MagicNumber) continue;
if(OrderOpenTime()>=Time[0]) Torg=false;
}
}
}
I hope I didn't delete anything I needed, otherwise the compiler would complain about the word else:
if(OrdersTotal()>0){// unnecessary line - if there are no orders, then the loop counter will be at zero and the loop will not be executed
for(int i=OrdersTotal()-1;i>=0;i--){// go through all orders
if (! OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){// if no order is selected, then...
if(OrderMagicNumber()!=MagicNumber) continue; //if the magic number is not ours, then proceed to another order
if(OrderOpenTime()>=Time[0]) Torg=false;
}
// But what if the order is still selected from the list?
}
}
P.S.
The line that signals an error number when selecting an order should not have been removed for some reason - it sometimes happens that it blows up. In general, error handling is better used wherever it can occur.
if(OrdersTotal()>0){// unnecessary line - if there are no orders, the loop counter will be at zero and the loop will not be executed
for(int i=OrdersTotal()-1;i>=0;i--){// go through all orders
if (! OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){// if no order is selected, then.
if(OrderMagicNumber()!=MagicNumber) continue; //if the magic number is not ours, then proceed to another order
if(OrderOpenTime()>=Time[0]) Torg=false;
}
// But what if the order is still selected from the list?
}
}
bool Torg;
if(OrdersTotal()==0) Torg=true;
if(OrdersTotal()>0){
for(int i=OrdersTotal()-1;i>=0;i--){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
if(OrderMagicNumber()!=MagicNumber) continue;
if(OrderOpenTime()>=Time[0]) Torg=false;
if(OrderOpenTime()<Time[0]) Torg=true;
}
}
}
How about this?
What if you try to check this loop in the script yourself? Well, just byprinting the result - what position the Torg variable takes in different cases. Do you think you can't do it yourself?
I don't think so.
Download - it will help - http://depositfiles.com/files/eg4fmn3bp