OrderType() always returns OP_BUY for sell orders. [SOLVED]

 

[Solved:  turns out I had created an enum called "OrderType" in another file which was shadowing and wreaking havoc. ]


Hi all,

I'm stuck.  For some reason my OP_BUYs are working, but when I try to open a OP_SELL, OrderType() always reports 0.

I'd be super-grateful if someone can help me with this.  Relevent code and journal results blow.  I'm on MT4 Version 4.0.0.1280 (4.0.0.1280) on a Macintosh.  Lemme know if you need more info.  First post ..

(Possible hint?  When I try to PrintFormat("%i", OrderType()) the compiler says void type expression is illegal)

if(ShortEntrySignal && (sqGetMarketPositionCount("Current", MagicNumber, 0, "") == 0)) {
         double orderPrice = MarketInfo(Symbol(), MODE_BID);
         double slPrice = calcStopLossPrice(OrderType::SELL, orderPrice, SL_pct);
         double tpPrice = calcTakeProfitPrice(OrderType::SELL, orderPrice, TP_pct);
         double orderSize = calculateOrderSize(Symbol(), AccountBalance(), percent_acct_risk, orderPrice, slPrice);

         PrintFormat("INPUTS to ORDERSEND:  Price: %f, orderSize: %f", orderPrice, orderSize);

         _ticket = OrderSend(Symbol(), OP_SELL, orderSize, orderPrice, 0, 0, 0);

         if(_ticket > 0 && OrderSelect(_ticket, SELECT_BY_TICKET)) {
            int orderType = OrderType();
            PrintFormat("ORDER TYPE of ticket %i: %i", _ticket, orderType);

            sqSetSLandPT(_ticket, slPrice, tpPrice);
         }
      }
   }
2021.09.12 19:01:06.979 2020.12.03 11:00:00  Chicken 3 EURUSD,H4: ORDER TYPE of ticket 2: 0
2021.09.12 19:01:06.979 2020.12.03 11:00:00  Chicken 3 EURUSD,H4: open #2 sell 0.46 EURUSD at 1.21115 ok
2021.09.12 19:01:06.979 2020.12.03 11:00:00  Chicken 3 EURUSD,H4: INPUTS to ORDERSEND:  Price: 1.211150, orderSize: 0.460000
 
jaybiz: .  I'm on MT4 Version 4.0.0.1280

Current version is 1345; upgrade and recompile.

 
William Roeder #:

Current version is 1345; upgrade and recompile.

Current versions is 1340. 1345 is a beta.
 

1280 seems to be the only one offered for macOS.  There's supposed to be a later one, but I can't find it and created another post about that.

I just had my friend run this EA on Windows (1340) and he had the same problem I'm having.