Login Page - Create Account

Support Board


Date/Time: Mon, 06 May 2024 10:24:11 +0000



Referencing Previous Bars using Alert Studies

View Count: 2055

[2018-04-29 02:46:46]
a Gem Tree - Posts: 60
Hello again SC.

I am trying to detect, using alert code, whether a specific event happened within the last few bars.
Right now, I am writing the condition to detect, bar by bar.
So if I want to detect if the event has happened within the last 20 bars, I have to write:
=and(ID1.SG1[-1]<X,ID1.SG1[-2]<X,etc,etc,etc)

Is there a way to more easily detect for events? Something that would only require 1 line of code, or perhaps a study that does this?
I know I can use spreadsheets to look for matches in an array, but that taxes my server's power too much.

Any help is much appreciated. Thank you for reading!
-Ben
[2018-04-30 16:09:53]
John - SC Support - Posts: 31379
The ability to do this was added in release 1735. You would need to update to that version to be able to use this feature.

The documentation for using a Range of Values in an Alert Formula is found here:
Study/Chart Alerts And Scanning: Referencing A Range of Data

To update, follow the instructions here:
Software Download: Fast Update
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2018-05-01 23:52:44]
a Gem Tree - Posts: 60
I think I love you guys. Hands down, you have the best platform, great indicators, and an awesome support board.
I can't wait to begin writing my own code for SC... Thank you for everything
-an old user.
[2018-05-02 18:37:09]
Sierra Chart Engineering - Posts: 104368
This particular formula cannot be directly rewritten using a range of values:

=and(ID1.SG1[-1]<X,ID1.SG1[-2]<X,etc,etc,etc)

A range is only going to be useful when used with a spreadsheet function which requires a range.
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

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

Login

Login Page - Create Account