[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 314

 
GarKain:

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?

no notice the error.

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?

 
drknn:


No. You don't need to declare a variable inside the loop at each iteration.

Hmmm... thanks
 
drknn:

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;
}
}
}
 
drknn:
Vladimir, the comrade has already been banned. Remove the link from the quote.
 
GarKain:

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.

 
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)){// 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?
}
}


How about this?

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;
}
}
}
 
GarKain:
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?
 
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?
I don't think so
 
GarKain:
I don't think so.

Download - it will help - http://depositfiles.com/files/eg4fmn3bp
 
GarKain: The classes are numbered from bottom to top. Press the lodge button and start with the scripts.
Reason: