Login Page - Create Account

Support Board


Date/Time: Wed, 10 Sep 2025 00:48:34 +0000



Post From: LifeCycle of sc.SupportTradingScaleOut in a study?

[2025-07-29 20:42:27]
rajeshh - Posts: 25
Thanks @sstfrederik again for the prompt help. Your code does work, although in my real example, the "next" cycle when sc.SupportTradingScaleOut = 0 has to work is the close of the bar, which I understand would be the last calcuation cycle for that bar, so then its not clear when I would set the persistent variable ( it would have to be something like a time check for a few seconds before the bar is about to close).

Not sure how I didnt find this article in my earlier search, but I found this thread Executing orders at bar close which discusses the same topic, and says not to use GetBarClosedStatus and there is code from somebody that is using the clock to determine when a bar is about to close and then SC support posted saying they have added a function -
sc.IsLastBarClosedBasedOnElapsedTime (sc.ChartNumber)
which will give me what I need. I did some initial testing with this, and it is working, however as the last comment on that thread says, it only works in live mode, whereas ideally I need it to work in replay mode as well.
Date Time Of Last Edit: 2025-07-29 21:22:24