Login Page - Create Account

Support Board


Date/Time: Wed, 12 Feb 2025 09:59:11 +0000



Post From: Automated Trading question on multiple orders

[2020-10-13 02:58:32]
TriStar Trading - Posts: 148
Hey! Any help would be appreciated. I am writing an order entry control bar with buttons. I have the following code for a Buy Market order:

      s_SCNewOrder EntryOrder;
      EntryOrder.OrderQuantity = OrderQuantity;
      EntryOrder.OrderType = SCT_ORDERTYPE_MARKET;
      EntryOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
      
      //Specify a Target and a Stop. Specifying one Target and one Stop, additional targets and stops can be specified.
      EntryOrder.Target1Offset = (SwingHighPrice - sc.Close[sc.Index]) + (TargetTicksOffset.GetFloat() * sc.TickSize);
      EntryOrder.Stop1Offset = (sc.Close[sc.Index] - SwingLowPrice) + (StopTicksOffset.GetFloat() * sc.TickSize);
      //EntryOrder.OCOGroup1Quantity = OrderQuantity; // If this is left at the default of 0, then it will be automatically set.
      
      int EntryResult = (int)sc.BuyEntry(EntryOrder);
      if (EntryResult < 0) //Order entry failed
      {
        sc.AddMessageToTradeServiceLog(sc.GetTradingErrorTextMessage(EntryResult), false, true);  
      }
The problem I am having is this. I enter an order for one contract. When I enter a second order for one contract, the position amount updates to two orders at the average price, but the target a stop orders do not seem to trigger for the second order. The quantities remain the same on the original stop and target orders, and alternatively no new stop and target orders are triggered.

Thanks in advance!

Mike