Login Page - Create Account

Support Board


Date/Time: Sun, 28 Apr 2024 13:31:52 +0000



[Programming Help] - Syntax for some event happened during the last x bars?

View Count: 668

[2017-06-06 20:34:06]
User947126 - Posts: 14
Hello,

This is not a suggestion, just a question--I'm wondering if it's possible to create a condition in an alert that specifies whether some event happened at any time during the last y bars. In other words, let's say that I want to know if the value of moving average #1 was greater than the value of moving average #2 at any point during the last five bars. The only way I know to do this is:

or(id1.sg1[-1]>id2.sg1[-1],id1.sg1[-2]>id2.sg1[-2],id1.sg1[-3]>id2.sg1[-3],id1.sg1[-4]>id2.sg1[-4],id1.sg1[-5]>id2.sg1[-5])

Is there a more economical way to do this--like some sort of way to specify a range of bars? Something like (and I'm making this up):

or(id1.sg1[-1:-5]>id2.sg1[-1:-5])?

Thanks
[2017-06-07 18:55:42]
Sierra Chart Engineering - Posts: 104368
No, there is no other easier way to do 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

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

Login

Login Page - Create Account