Login Page - Create Account

Support Board


Date/Time: Sun, 12 Jul 2026 23:59:23 +0000



[Programming Help] - ACSIL Help.. while loop exploding SC

View Count: 163

[2026-05-22 20:42:13]
User884965 - Posts: 3
Hello,

I'm trying to create a custom study. At certain points in the code I have while loops that look something like:


if (x1 > y1)
{
sc.AddMessageToLog("x1 > y1");

while (true)
{
sc.AddMessageToLog("x1 > y1, while (true)");

if (x2 >= y2)
break;
if (x3 <= y3)
continue;
}
}

The study runs fine until one of the while loops are hit, at which time the Sierra Chart program crashes.

The messages were added for debugging after the first few time it crashed. The logs show the equivalent of:

2026-05-22 00:00:00.000| Messages | x1 > y1
2026-05-22 00:00:00.000| Messages | x1 > y1, while (true)
2026-05-22 00:00:09.500| Messages | x1 > y1, while (true) | Number times message previously added: 42003603
(with both automatic and manual looping if that matters)

I need the computing to stay inside the while loop until the condition is met which breaks it (x2 >= y2 in the example).
I also need SC to not loop through so fast that it K/O's itself. I tried looking through the looping documentation but couldn't find anything that looked like it would solve this issue.

Am new to ACSIL and aware that the issue may be entirely my coding. Any help is appreciated.
[2026-05-23 14:35:10]
ForgivingComputers.com - Posts: 1231
You created an infinite loop. The values x2, x3, y2, and y3 will never change inside the loop, so unless x2 >= y2 when entering the loop, there is no break and no exit.
[2026-05-23 14:41:58]
User431178 - Posts: 891
Am new to ACSIL and aware that the issue may be entirely my coding. Any help is appreciated.

You might find this useful.

https://www.learncpp.com/
https://www.learncpp.com/cpp-tutorial/introduction-to-loops-and-while-statements/
[2026-05-23 15:18:01]
Sierra_Chart Engineering - Posts: 24242
Remove the use of the while loop. You cannot use that, in an ACSIL function in the way that you are and actually that is terribly inefficient in any case unless there is a small finite number of iterations and something actually being performed within the while loop.

We recommend using manual looping in ACSIL:
Working with ACSIL Arrays and Understanding Looping: Manual Looping/Iterating

If you are waiting for a particular condition to occur, then add an if statement, somewhere after the sc.SetDefaults code block and check for that condition and if it is not true, then just simply return from the study function.
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: 2026-05-23 20:18:15

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account