Support Board
Date/Time: Sat, 23 Nov 2024 12:15:32 +0000
[Programming Help] - How often CPP programs get executed
View Count: 168
[2024-08-21 16:11:10] |
User935839 - Posts: 2 |
Hi guys I'm confused on how often CPP programs get executed during live/playback session. i come from Ninjatrader c# trading and it was easy to know how often code get executed (each new tick/each bar close ... ) . However i dont get it in Sierra,, like i want my code to get executed every chart bar close, i trying that just to see how often it get called : if(sc.GetBarHasClosedStatus(sc.Index)==BHCS_BAR_HAS_NOT_CLOSED) { {sc.AddMessageToLog("to execute only once per bar", true);} // return;//do not do any processing if the bar at the current index has not closed } the result on logs is like having new log each +/-9 seconds ,,, which is not really coherent ... i just want my code to get executed at very moment of bar close whatever the timeframe on my chart is . i wish my question is clear enough and u can help me , Thanks a lot |
[2024-08-21 17:07:24] |
Sierra_Chart Engineering - Posts: 17145 |
Refer to: Working with ACSIL Arrays and Understanding Looping: When the Study Function is Called If you want the study function to be guaranteed to be called when a bar closes, and not at the time a new bar is added to the chart, then you need to use this variable: ACSIL Interface Members - Variables and Arrays: sc.UpdateAlways 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, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-08-21 17:52:16] |
User935839 - Posts: 2 |
Guys, stupid to say , but i cant achieve to write one log message each time bar closes, whatever the timeframe is ... i tried all different combinations of flags (sc.AutoLoop, sc.UpdateAlways , sc.UpdateStartIndex..). but cant achieve it, looks like the program executes randomly which is weird
|
[2024-08-21 18:22:52] |
Sierra_Chart Engineering - Posts: 17145 |
The most reliable way to know a chart bar closes is when a new one is added. So if a chart bar at index 99 closes, you will know that, when a chart bar at index 100 is added. The sc.ArraySize would change from 100 to 101.
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, use the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2024-08-21 18:23:17
|
[2024-08-22 00:36:33] |
ForgivingComputers.com - Posts: 960 |
Since you used sc.Index, that implies you are using sc.AutoLoop = 1;
In which case you do not specify the index for the status function. This is what you need: if(sc.GetBarHasClosedStatus()==BHCS_BAR_HAS_NOT_CLOSED)
{ return;//do not do any processing if the bar at the current index has not closed } else sc.AddMessageToLog("to execute only once per bar", true); |
To post a message in this thread, you need to log in with your Sierra Chart account: