Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 19:52:00 +0000



[Programming Help] - how to pass an alert condition to sc.EvaluateAlertConditionFormulaAsBoolean function?

View Count: 2198

[2019-02-13 22:25:39]
User997668 - Posts: 13
Hi,

I need to build systems using ACSIL ONLY. (not spreadsheets or the trading studies from SC).

I need to evaluate multiple conditions at run time and require the performance optimization that comes from the "internal formatting and storage" of the conditions as documented in:

sc.EvaluateAlertConditionFormulaAsBoolean()

But how do we pass an alert condition to the sc.EvaluateAlertConditionFormulaAsBoolean() function? there is no input for that? I don't want to use multiple SC studies just to add the alert in the "Alert" box.

Can create a version of this function that accepts a condition text input?

thanks
[2019-02-14 00:34:12]
User525733 - Posts: 126
I was wondering the same thing myself.....why give us a function we can't even use ? probably an oversight by the SC dev team.
[2019-02-14 03:15:48]
User90125 - Posts: 715
+1
[2019-02-14 16:52:06]
Sierra Chart Engineering - Posts: 104368
We will have to add a new function to support specifying the alert formula. We will see about that. If it is easy we will try to get it done today.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-02-15 18:22:44]
User525733 - Posts: 126
do you think we can get this by early next week?
[2019-02-16 16:24:55]
Sierra Chart Engineering - Posts: 104368
This will be completed today.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-02-17 19:09:41]
User525733 - Posts: 126
thanks guys,
just wondering; does the alert condition string have the same characters limit as in the studies...~400 characters?
[2019-02-17 19:19:55]
Sierra Chart Engineering - Posts: 104368
No, there is no limit.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-02-24 04:20:52]
User525733 - Posts: 126
i am confused about how often " ParseAndSetFormula" needs to be set to 1.

documentation states "It is necessary to set ParseAndSetFormula to a nonzero value the first time running this function or whenever the alert formula changes. It should not be set to a nonzero value every time because it is not efficient doing that."

yet in the "Trading system based on alert condition" study...."ParseAndSetFormula" is set to 1 every time the study is updated (after the initial full calculation).

Is it ok to set "ParseAndSetFormula" to 1 on a sc.IsFullRecalculation check and leave it at 0 otherwise?

in other words, does the internal formatting and storage of the condition get saved between study calls or it needs to be redone on every call after the initial full study calculation?
[2019-02-24 04:52:04]
Sierra Chart Engineering - Posts: 104368


yet in the "Trading system based on alert condition" study...."ParseAndSetFormula" is set to 1 every time the study is updated (after the initial full calculation).
Yes we see this and it does need to be but it is not really inefficient because that study uses manual looping but we are going to change this to only do it on a full recalculation.


in other words, does the internal formatting and storage of the condition get saved between study calls
Yes this is true.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2019-02-24 04:52:18
[2019-02-24 10:30:15]
@sstfrederik - Posts: 404
It is my understanding that the alert condition is taken from the Alerts tab of the study where this function is used.

So this function is quite useful as is.

You can always work with a reference to a "color bar based on alert condition" study to do multiple alert condition evaluations.
Date Time Of Last Edit: 2019-02-24 10:33:09
[2019-02-26 00:11:47]
User525733 - Posts: 126
folks, did you remove the new function? i just updated 1875 (26261:26262) and can't access it.
[2019-02-26 00:25:03]
User525733 - Posts: 126
The new function I am referring to is :

sc.EvaluateGivenAlertConditionFormulaAsBoolean()

can you please roll it out.
[2019-02-26 00:40:39]
Sierra Chart Engineering - Posts: 104368
You need to use the very latest prerelease for that function. Which is now 1879.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-02-26 05:37:21]
User525733 - Posts: 126
guys, has the new function ( sc.EvaluateGivenAlertConditionFormulaAsBoolean ) been fully implemented?

They're always returning True no matter the condition used.

FYI, I always pass the condition even when ParseAndSetFormula is set to 0.

I also tried sc.EvaluateGivenAlertConditionFormulaAsDouble...same thing.

thanks
[2019-02-26 17:38:43]
User997668 - Posts: 13
I am seeing the same weird behavior as well....perhaps i am using the new function incorrectly. Here is what i am doing:

I am using AUTOLOOPING + "sc.CalculationPrecedence = LOW_PREC_LEVEL" and evaluating MULTIPLE conditions each time the study is called:


bool ParseAndSetFormula = sc.IsFullRecalculation;

SCString Condition1 = "0"; // sanity check test
int Condition1_result = sc.EvaluateGivenAlertConditionFormulaAsBoolean(sc.Index,ParseAndSetFormula,Condition1);
  
SCString Condition2 = "ID1.SG1 = 0";
int Condition2_result = sc.EvaluateGivenAlertConditionFormulaAsBoolean(sc.Index, ParseAndSetFormula, Condition2);
  
SCString Condition3 = "ID2.SG1 = 0";
int Condition3_result = sc.EvaluateGivenAlertConditionFormulaAsBoolean(sc.Index, ParseAndSetFormula, Condition3);

Condition1_result returns 0 initially then becomes 1 ! The other conditions evaluate to wrong outcomes as well.

I am not sure what I am doing wrong.
[2019-02-26 23:12:37]
Sierra Chart Engineering - Posts: 104368
We are going to be doing some testing. A basic test is not revealing a problem . So we are going to go into more detail on this.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-02-26 23:15:06]
Sierra Chart Engineering - Posts: 104368
Okay, we just realized what the problem is. You do have to set ParseAndSetFormula to 1 anytime you specify a different formula. So the code given in post 16 always needs to set ParseAndSetFormula to 1 because you are using more than one formula. So this is going to be less efficient.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-02-27 09:52:49]
Sierra Chart Engineering - Posts: 104368
In regards to post #15, one thing to be aware of with these functions and we will document this, is that you cannot use an Alert formula entered on the Alerts tab of the Study Settings for the same study. The formula you give this function and the formula on the Alerts tab are going to conflict with each other.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-02-28 16:33:02]
User525733 - Posts: 126
say,

if i want to build the alert condition based on user input (using sc.GetstudyID and sc.GetsubgraphIndex ) would putting this stuff inside the

if (sc.SetDefaults)
{
}

block help make the process more efficient? i don't want to expend processing time rebuilding the alert condition on every call to the study.
[2019-02-28 21:15:13]
Sierra Chart Engineering - Posts: 104368
No you just need to do that when sc.FullRecalculation is 1. It needs to be outside of the SetDefaults code block.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2023-07-14 19:07:19]
j4ytr4der_ - Posts: 938
This is an old thread but I'm just now attempting to use sc.EvaluateGivenAlertConditionFormulaAsDouble, in order to get a calculated value from a study and pass it to another study.

From reading the docs, it seems that this function does *not* get its value from the Alerts tab of the study it's used on, but instead has to have the formula passed in. Is this correct? Ideally it would just receive the result of the alerts formula tab in the study it's already on, but if I can't do that, what is the proper way?

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

Login

Login Page - Create Account