Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 01:58:21 +0000



Post From: Issues about sc.CancelAllOrders()

[2024-07-10 14:53:20]
Tony - Posts: 516
Hi,

I am trying to cancel stop order when there is no position by using sc.CancelAllOrders(), everything works great until I press "Insert" key to reload and recalculate the chart, the stop order disappeared even I still had a position, so I tried to fix the issue by doing this:


  if (sc.IsChartDataLoadingInChartbook() || sc.IsFullRecalculation || sc.ChartIsDownloadingHistoricalData(sc.ChartNumber)) {
    // do something
  }

  else {
    s_SCPositionData PositionData;
    sc.GetTradePosition(PositionData);

    if (PositionData.AveragePrice == 0.0) {
      sc.CancelAllOrders();
    }
  }

But the stop order still got canceled after reload and recalculation while I had an open position.

Wonder what I had missed,

Thanks!

P.S.
Originally, the stop order also got canceled after I remove and add this custom study, that part has been fixed by adding the code showed above.
Date Time Of Last Edit: 2024-07-10 15:25:58