Quote:
|
Originally Posted by ralph.ronnquist
PHP Code:
bool opened_on_current_bar = false;
for (int i = OrdersTotal() - 1; i >=0; i-- ) {
if ( ! OrderSelect( i, SELECT_BY_POS ) )
continue;
if ( OrderOpenTime() >= Time[ 0 ] ) {
opened_on_current_bar = true;
break;
}
}
// Here the variable opened_on_current_bar is set appropriately
|
Nice code but the condition OrderOpenTime() >= Time[0] will not work.
First some basic information:
OrderOpenTime() and Time[] are int's and they are like timestamp.
Time[0] is the current time value.
But lets say that we will use normal hours just for education purposes.
Assuming that we are currently on bar 12.00 on 1h chart, we open trade at 12.01, and lets say that we are 1 minute after that time (12.02).
Now lets check this condition:
if 12.01 >= 12.02 opened_on_current_bar = true;
will this code work ? I don't think so. And where is the magic number condition? Hm... try again
