Help with OrderComment()

 

Hello,

I need EA to check opened market orders (BUY and SELL) and IF NEW bar - Open[0] is NOT equal to some of other opened orders BarOpenPrice - which is printed to OrderComment of each order to open new order. Of course if there is no open order at terminal this is not the case.

 
MINTA:

Hello,

I need EA to check opened market orders (BUY and SELL) and IF NEW bar - Open[0] is NOT equal to some of other opened orders BarOpenPrice - which is printed to OrderComment of each order to open new order. Of course if there is no open order at terminal this is not the case.

Some of code need corections. Can somebody help?

It's a bad idea to use Order comments . . . they can be modified or replaced by your Broker.
 
MINTA:
IF NEW bar - Open[0] is NOT equal to some of other opened orders BarOpenPrice - which is printed to OrderComment of each order to open new order.
  1. brokers can change comments, including complete replacement. Ref
  2. doubles rarely compare equal/notEqual See Can price != price ? - MQL4 forum and Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
  3. int ordticket[][2];
    :
    ordticket[orders][0] = OrderOpenTime();
    Will not work as you never resize the array BEFORE using it.
  4. Always test return codes. If your order select fails, so does the rest of the loop.
        for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if(
            OrderSelect(iPos, SELECT_BY_POS)              ) if( // Only my orders w/
            OrderMagicNumber() == magic.number            ) if( // my magic number,
            OrderSymbol()      == chart.symbol            ){    // and my pair.
    

  5. iOpen(NULL,0,integer)
    Why use a function call when you can use the simplier Open[integer]?
  6. You know when the order was opened, find the corresponding bar and get the open
    :
    datetime OOT = OrderOpenTime();
    int      iOOT = iBarShift(NULL,0, OOT);
    double   openAtopen = Open[iOOT];
Reason: