Login Page - Create Account

Support Board


Date/Time: Mon, 23 Dec 2024 19:18:59 +0000



Post From: s_SCTradeOrder order lifetime

[2015-09-27 18:16:53]
Sierra Chart Engineering - Posts: 104368
Here is a code example. One of the function calls in this code requires version 1300 which has not yet been released.

SCSFExport scsf_TradingExampleIteratingOrderList(SCStudyInterfaceRef sc)
{

  if (sc.SetDefaults)
  {
    // Set the study configuration and defaults.

    sc.GraphName = "Trading Example: Iterating Order List";

    // This is false by default.
    sc.SendOrdersToTradeService = false;

    sc.AutoLoop = 0;
    sc.GraphRegion = 0;

    sc.FreeDLL = 0;

    return;
  }

  // This only serves as a code example and we do not want this code to run.
  return;


  // This is an example of iterating the order list in Sierra Chart for orders
  // matching the Symbol and Trade Account of the chart, and finding the orders
  // that have a working Order Status and are not Attached Orders.

  //The iteration must always be from zero until SCTRADING_ORDER_ERROR is returned. Do not reverse iterate because that is highly inefficient. sc.GetOrderByIndex is less efficient than using sc.GetOrderByOrderID. So it should not be called frequently.
  int Index = 0;
  s_SCTradeOrder OrderDetails;
  while( sc.GetOrderByIndex(Index, OrderDetails) != SCTRADING_ORDER_ERROR)
  {
    ++Index; // Increment the index for the next call to sc.GetOrderByIndex

    if (!IsWorkingOrderStatus(OrderDetails.OrderStatusCode))
      continue;

    if (OrderDetails.ParentInternalOrderID != 0)//This means this is an Attached Order
      continue;

    //Get the internal order ID
    int InternalOrderID = OrderDetails.InternalOrderID;

  }



  int TargetInternalOrderID = -1;
  int StopInternalOrderID = -1;

  //This needs to be set to the parent internal order ID search for. Since we do not know what that is in this code example, it is set to zero here.
  int ParentInternalOrderID = 0;

  sc.GetAttachedOrderIDsForParentOrder(ParentInternalOrderID, TargetInternalOrderID, StopInternalOrderID);
}

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2015-09-27 18:17:46