The next function closes orders in my EA. It works fine while the 3rd if(...)
-code-block is quoted-out.
When it is activated in the function, MT4 stops and W7 pops up with a message saying there's a problem with the program (MT4). Defining the variable prijsOpen
or not makes no difference.
Can anybody tell me what's wrong??
void sluitBUY( double waarde ){
for ( int i = 0; i < OrdersTotal(); i++ ){
if ( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == true ){
double prijsOpen = OrderOpenPrice();
if ( OrderType() == 0 ){
if ( waarde != 0
&& prijsOpen < waarde
) //<============================================ CAUSES CRASH
OrderClose( OrderTicket(),
OrderLots(),
OrderClosePrice(),
3,
clrCyan
);
}
}
}
}