Why this doesn't work - order.Type()

 

Hi,

I need some help with this code, After I placed BuyStop order the following is executed

void OnTrade()

int o_total = OrdersTotal(); 

    

        for (int j=0; j<o_total; j++)

          if (myorder.Select(OrderGetTicket(j)))            

               if (myorder.Type() == ORDER_TYPE_BUY_STOP)

                              signal_time=myorder.TimeSetup(); 

Print (TimeToString(signal_time,TIME_DATE|TIME_MINUTES));

 signal_time is defined as global datetime, print gives WRONG_VALUE (which is assign on Init());

Works if I skip part

if (myorder.Type() ==ORDER_TYPE_BUY_STOP)

 

If I try to print value of myorder.Type() is 0, where  ORDER_TYPE_BUY_STOP is 4; 

Is't this has something to do with time, when I send query (onTrade) ?

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 

Just figured this out if anyone interested

should be

myorder.OrderType()

myorder.Type() is virtual int from CObject, always returning 0..