Login Page - Create Account

Support Board


Date/Time: Thu, 25 Apr 2024 04:53:12 +0000



[Programming Help] - Loop Statements with Color Bar Based on Alert Condition

View Count: 619

[2020-07-06 17:22:00]
MecGrp - Posts: 12
I am trying to put the following statement in a loop because it appears there a a character limitation on the Alert condition formula.

I want it to loop/calculate 'x' number of times/bars. But not to be confused with just calculating "x numbers of bars ago"

AND(
ID21.SG1 > 0,
ID21.SG1 > (IF (ID21.SG1[-1]<0,(ID21.SG1[-1]*-1),ID21.SG1[-1])),
ID21.SG1 > (IF (ID21.SG1[-2]<0,(ID21.SG1[-2]*-1),ID21.SG1[-2])),
ID21.SG1 > (IF (ID21.SG1[-3]<0,(ID21.SG1[-3]*-1),ID21.SG1[-3]))
)

Any help will greatly be appreciated.
[2023-01-22 13:33:03]
User233426 - Posts: 4
Hello,
this is my question now, how can I use loops and variables in this study ?
regards
[2023-01-23 18:27:53]
John - SC Support - Posts: 31098
Alerts do not have any support for looping or variables. You would have to create a custom study to have access to those tools. Refer to the following:
How to Build an Advanced Custom Study from Source Code
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2023-01-25 11:39:04]
User233426 - Posts: 4
I need a small code for custom study that will give an alert in the following condition:

ID1.SG1 > ID1.SG2

If I have such a code, I will develop it myself.
Thank you very much for your kindness
Date Time Of Last Edit: 2023-01-25 11:39:52

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

Login

Login Page - Create Account