Login Page - Create Account

Support Board


Date/Time: Tue, 11 Mar 2025 17:40:23 +0000



[Programming Help] - referencing common global variable in alert formulas

View Count: 867

[2022-04-17 10:51:50]
User12089 - Posts: 365
lets say there are multiple alert conditions in various studies, ALL on the SAME chart

is there any way to setup a common global variable (if necessary inside / as part of yet another study) which can then be referenced FROM ALL alert formulas

in e.g. logical conditions like H > Global Var

hence when the value assigned to Global Var is changed once in the single central place/study, all other alert formulas in studies on the same chart will start refering to the new value assigned to Global Var
[2022-04-17 11:47:51]
ForgivingComputers.com - Posts: 1021
All subgraphs within a chart are visible to all studies within the chart. The output (SG) of any study can be part of an alert formula by referencing its ID and SG. So ID1SG1 is basically a Global Variable. ("Global" is defined as within the chart.)

A Spreadsheet Formula Study (ID1) can be used, where the output of the study (SG1) is available to all other studies as ID1SG1.
[2022-04-17 12:04:48]
User12089 - Posts: 365
basically by Global Variable i mean defining and then referencing a Global Constant (as the Constant can be changed from one single place). So thats a little different from referencing the (standard) outputs from other studies

secondly, the Global Constant is supposed to be referenced in range of past bars formula expressions e.g. [-1: Global Constant]

so are we saying that a constant value can be defined in e.g. a spreadsheet study and then from there referenced in alert formula expressions of the type [-1: Global Constant]?
[2022-04-17 16:19:21]
ForgivingComputers.com - Posts: 1021
so are we saying that a constant value can be defined in e.g. a spreadsheet study and then from there referenced in alert formula expressions of the type [-1: Global Constant]?

They would be referenced by an IDxSGy. Column K in the Spreadsheet Studies is SG1, Col J is SG2, etc.
[2022-04-17 16:20:30]
ForgivingComputers.com - Posts: 1021
You can also use the Horizontal Lines Study to create Constant Values.
[2022-04-23 11:25:16]
User12089 - Posts: 365
does NOT work in range of bars expressions like this (copy paste from above):

secondly, the Global Constant is supposed to be referenced in range of past bars formula expressions e.g. [-1: Global Constant]
Date Time Of Last Edit: 2022-04-23 11:25:52
[2022-04-23 12:21:47]
ForgivingComputers.com - Posts: 1021
[-1: Global Constant]

I don't understand your example.
[2022-04-23 12:56:02]
Sawtooth - Posts: 4182
Specifying a range in Simple Alerts is limited to the bar index, and is further limited to a direct entry, not a referenced variable.

You will need to use a spreadsheet study to do what you want.
[2022-05-01 14:30:22]
User12089 - Posts: 365
smashing, thanks Tom, not only understood what was asked here but also provided a solution

great web site btw https://www.sawtoothtrade.com/example-10.html
Date Time Of Last Edit: 2022-05-01 14:32:22

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

Login

Login Page - Create Account