Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 01:23:06 +0000



Post From: Issues about sc.CancelAllOrders()

[2024-07-10 19:46:09]
Tony - Posts: 516
Hi bradh and User431178,

Thanks so much for the feedback, unfortunately I tried all the possible solutions, none of them works.

I get around the issue by delaying the open-position check for a few loops right after reload / recalculation:

static int LoopCount {0};
LoopCount++;

So this number will be increased by 1 per loop through the lifespan of the study, but will be reset to 0 every time reload or recalculate happened.

And open-position check only happens when the value of LoopCount is greater than a certain number, i.e. 3

Now the stop order will never be canceled when there is an open position, as I expected.

I think I misunderstood with either of these 3 function / variable:
sc.IsChartDataLoadingInChartbook()
sc.IsFullRecalculation
sc.ChartIsDownloadingHistoricalData(sc.ChartNumber)

I hope engineering team will have a better solution, my code looks ugly now.
Date Time Of Last Edit: 2024-07-11 05:44:45