Login Page - Create Account

Support Board


Date/Time: Fri, 01 Nov 2024 00:08:30 +0000



Post From: OCO_LIMIT_STOP_ORDER with attached target and stop orders

[2017-02-21 22:22:45]
User953407 - Posts: 5

// Create an s_SCNewOrder object.
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = 1;
NewOrder.OrderType = SCT_ORDERTYPE_OCO_LIMIT_STOP;
NewOrder.Price1 = limitPrice;
NewOrder.Price2 = stopPrice;
NewOrder.TimeInForce = SCT_TIF_DAY;

//Specify a Target and a Stop. We are specifying one Target and one Stop, additional targets and stops can be specified as well.
NewOrder.Target1Offset = limitOrder_Target_Offset;
NewOrder.Target1Offset_2 = stopOrder_Target_Offset;
    
NewOrder.Stop1Offset = stopOrder_Stop_Offset;
NewOrder.Stop1Offset_2 = stopOrder_Stop_Offset;  

I am specifying an order as above. When the order gets executed I get the IDs of the attached orders.


  if (Result > 0) //If there has been a successful order entry, then draw an arrow at the low of the bar.
  {
  
   // Remember the order IDs for subsequent modification and cancellation
    Target1OrderID = NewOrder.Target1InternalOrderID;
    Stop1OrderID = NewOrder.Stop1InternalOrderID;
        
    Target2OrderID = NewOrder.Target1InternalOrderID_2;
    Stop2OrderID = NewOrder.Stop1InternalOrderID_2;
  }

The when the position is not 0, I am checking which orders are live and I get all four of them!!!
by checking if sc.GetOrderByOrderID(Target1OrderID, ExistingOrder) != SCTRADING_ORDER_ERROR

How can this be true?