Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 10:36:27 +0000



[Programming Help] - Problem with Alert being triggered multiple times

View Count: 262

[2023-12-11 09:59:40]
BenjFlame - Posts: 324
Hi,
this is code but It could be a general problem so it's not "programming help".

On my ACSIL code I have:


bool BarHasClosed = sc.GetBarHasClosedStatus(sc.Index) != BHCS_BAR_HAS_NOT_CLOSED;
if (BarHasClosed)
{
sc.PlaySound(30, "test alert message");
}

Any time I load chart or modify it, that alert will trigger 24 times.
I see no reason for this. What is the cause?

Then, it will trigger properly upon BarHasClosed. The problem is really upon initial load or modification.
Date Time Of Last Edit: 2023-12-11 10:02:59
[2023-12-12 16:01:15]
BenjFlame - Posts: 324
Problem doesn't come from alert itself, but from BarHasClosed that is run multiple times upon any chart modification such as adding or removing study.

Is there a reliable way to force alert to run only once per bar, when triggered from ASCIL sc.PlaySound?
On Global Settings >> General Settings >> Alerts where I can set alert trigger parameters, I don't find way to enforce this. The "Number of Times to Play this alert" seems not respected.
It would be good in this alert setting screen if we can have the traditional alert options, such as "run once per bar"
Date Time Of Last Edit: 2023-12-12 16:02:43
[2023-12-12 16:23:41]
User431178 - Posts: 543
Try using SetAlert instead - sc.SetAlert()

or maybe replace


if (BarHasClosed)
{
sc.PlaySound(30, "test alert message");
}

with


if (BarHasClosed && !sc.IsFullRecalculation)
{
sc.PlaySound(30, "test alert message");
}

[2023-12-12 20:25:23]
Sierra_Chart Engineering - Posts: 17179
Yes you will not want to use sc.PlaySound. You are playing a sound for every chart bar except the last one.
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: 2023-12-12 20:25:33

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

Login

Login Page - Create Account