Login Page - Create Account

Support Board


Date/Time: Tue, 25 Feb 2025 01:25:26 +0000



Post From: Study function keeps getting called even when the new bar is not added to chart

[2021-03-23 19:35:17]
User741184 - Posts: 44
Hi,

My chart's Bar Period Type is set to Volume Per Bar(setting 7500). And in my code I am printing sc.Index to Sierra Chart's log and also to the file to see how many bars are there in the chart. Also the automatic looping has been set. Here is the code snippet.


SCString MessageText;
sc.AddMessageToLog(sc.Index, 0);

// Create and open a text file
std::ofstream MyFile("filename.txt", std::ios::app);

// Write to the file
MyFile << sc.Index << std::endl;

// Close the file
MyFile.close();

Now as per the documentation, When your study function uses automatic looping, then it is automaticaly called once for every bar or column in the chart when the study is initially calculated. If there are 100 bars in the chart, then it will be called 100 times when your study is initially calculated. After that, the study function is called as the latest bar is updated and new bars are added. But the problem is, after printing 100 times the study gets called every few milliseconds as I can see the log message being printed every few milliseconds. The file also keeps updating at the same rate. The new bar is not available after few milliseconds then why the study function is being called again and again?