Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 07:42:22 +0000



Post From: Help finding the nearest stop order id for move to break even button

[2024-06-19 04:41:56]
TriStar Trading - Posts: 142
Hey all you wizards out there. I'm attempting to program a button to move a stop order to break even. Just like the one on the Trade Window. Need it floating and bigger on a toolbar. Does anyone know how to find the nearest stop order internal id if it is not an attached order? Also, if it is an attached stop order, would the code need to be different to move it to break even. Here is what I have so far. Thanks in advance! Mike

  if (sc.MenuEventID == Input_ACSButtonNumber.GetInt())
  {
    if (PositionData.PositionQuantity < 0 &&  //Short Position
      sc.Close[sc.Index] < PositionData.AveragePrice) //Current price less than position price
    {
      //Stop to BE
      s_SCTradeOrder ExistingStopOrder;
      int OrderID = sc.GetNearestStopOrder(ExistingStopOrder);

      s_SCNewOrder ModifyOrder;
      ModifyOrder.InternalOrderID = OrderID;
        
      float NewStopPrice = PositionData.AveragePrice;
      ModifyOrder.Price1 = NewStopPrice;
    }
  }