Getting Order Status


Use GetOrderStatus() to check the status of an existing order.  This function returns a string value.


FILLED Order Filled
PENDING Order is Pending (not filled)
CANCELLED Order has been Cancelled
NO CONNECTION No Connection to Broker
NOT FOUND Order not found in MTS

  

An example of using GetOrderStatus() is below...


//  fire new order to MTS

NewEntryOrder = mentts.call("PlaceOrder","GAIN","BUY","MARKET",tempsymbol,(GAINMultiplier*DefEntryContracts),0,"GTC","","","",0);

TradePending = true;

TradeDirection = 1;  //long


if ((NewEntryOrder > 0) && (TradePending)) {

       //  new order placed successfully.

      var OrderStatus = mentts.call("GetOrderStatus","GAIN",NewEntryOrder);

      if (OrderStatus  == "FILLED") {

         if (TradeDirection > 0) { //  long

            StrategyisInTrade = true;

            StrategyisLong = true;

            StrategyisShort = false;

            TradeAmount = mentts.call("GetFillAmount","GAIN",NewEntryOrder);

            EntryPrice = mentts.call("GetFillPrice","GAIN",NewEntryOrder);

       TradePending = false;

            TradeDirection = 0;

         }

         if (TradeDirection < 0) { //  Short

            StrategyisInTrade = true;

            StrategyisLong = false;

            StrategyisShort = true;

            TradeAmount = mentts.call("GetFillAmount","GAIN",NewEntryOrder);

            EntryPrice = mentts.call("GetFillPrice","GAIN",NewEntryOrder);

       TradePending = false;

            TradeDirection = 0;

         }

      }

      if (OrderStatus  == "CANCELLED") {

       TradePending = false;

            TradeDirection = 0;

       NewEntryOrder = 0;

      }

}