0

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
                            );
          }
       }
   } 
}
user3666197
  • 1
  • 6
  • 50
  • 92

1 Answers1

0

I don't see anything wrong with the code you provided. But I have seen the behavior that you are describing. Your MT4 platform may be corrupted. Try the same code on a different instance of MT4 and see if it still has the same problem. I'm guessing that it won't.

Tony Manso
  • 31
  • 5