Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 08:44:27 +0000



Post From: Sending Orders for Multiple Symbols

[2024-03-18 22:34:58]
Gradient - Posts: 89
Hi,

I've implemented logic to submit orders for multiple symbols from a single chart.

I'm reading in the BaseData of the reference chart and storing the last price in a subgraph array (See Below)

// Define a graph data object to get all of the base graph data
  SCGraphData BaseGraphData;

  // Get the base graph data from the specified chart
  sc.GetChartBaseData(ChartNumber.GetInt(), BaseGraphData);

  // Define a reference to the High array
  SCFloatArrayRef LastArray = BaseGraphData[SC_LAST];

  // Array is empty. Nothing to do.
  if(LastArray.GetArraySize() == 0){

  return;
  }
  
  // Get the index in the specified chart that is
  // nearest to current index.
  int RefChartIndex =
  sc.GetNearestMatchForDateTimeIndex(ChartNumber.GetInt(), sc.Index);

  double NearestRefChartLast = LastArray[RefChartIndex];
  
  //store other symbol price
  sc.Subgraph[5][sc.Index]=NearestRefChartLast;


The data from the reference chart is being read into the current chart, however, I've noticed multiple bugs with submitting orders.

When attempting to submit orders on a minute based intraday chart, orders are being executed for one symbol (the base symbol).

No orders are appearing for the other symbol.

When I check the working orders I can see orders submitted for the second symbol but I also see a growing list of submissions. The second symbol will have new order submissions every second or so but no positions. Also there are no fills or positions in the chart of the second symbol.

I also noticed that for the base symbol (i.e. the chart that contains the study), even though I'm simply submitting a limit order, it continuously places OCO orders.

Below is an example of the order submission:

//symbol 1
      Symbol1ParentOrder.OrderQuantity=1;
      Symbol1ParentOrder.OrderType=SCT_ORDERTYPE_LIMIT;
      Symbol1ParentOrder.TimeInForce=SCT_TIF_IMMEDIATE_OR_CANCEL;
      //Symbol1ParentOrder.MaximumChaseAsPrice=1.0/2;
      Symbol1ParentOrder.Price1=sc.Close[sc.Index];
      
      
//symbol 2
      Symbol2ParentOrder.Symbol=symbol;
      Symbol2ParentOrder.OrderQuantity=1;
      Symbol2ParentOrder.OrderType=SCT_ORDERTYPE_LIMIT;
      Symbol2ParentOrder.TimeInForce=SCT_TIF_IMMEDIATE_OR_CANCEL;
      //Symbol2ParentOrder.MaximumChaseAsPrice=1.0/2;

//get price of other symbol from subgraph array
      Symbol2ParentOrder.Price1=sc.Subgraph[5][sc.Index];
      
      
            
      //send order
      int response=static_cast<int>(sc.BuyEntry(Symbol1ParentOrder));
      int sym2Response=static_cast<int>(sc.BuyOrder(Symbol2ParentOrder));
      
I've attached an example of the OCO order being sent on the base symbol chart even though I'm not submitting an OCO order.

Can someone advise how to resolve these issues? Thanks.
Date Time Of Last Edit: 2024-03-18 22:45:40
imageOCO Error 1.png / V - Attached On 2024-03-18 22:44:29 UTC - Size: 14.31 KB - 73 views