Login Page - Create Account

Support Board


Date/Time: Wed, 15 May 2024 14:51:42 +0000



[Programming Help] - Reference previous range of bars

View Count: 1865

[2018-06-02 09:18:11]
chart_warrior - Posts: 96
I'm trying to reference previous 6 bars to compare if current delta is higher than the last 6 bars.
It's part of a bigger code but the issue I'm having is specifically with this condition which doesn't return the right value based on looking at the chart:

=ID2.SG4 > OR(ID2.SG4[0:-6])


ID2.SG4 is cumulative delta close

I do not get any errors however by looking at the chart I can see that current delta is lower than any of the last 6 bars and it's still showing a dot.
[2018-06-02 12:25:31]
Sierra Chart Engineering - Posts: 104368
This does not make sense:
OR(ID2.SG4[0:-6])

We would have to test what would happen but most likely this is always going to return 1.
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
[2018-06-02 18:47:14]
chart_warrior - Posts: 96
I agree, doesn't make sense to me either. I would write something like this instead but it's complaining about syntax: =ID2.SG4 > ID2.SG4[0:-6].
If this is not right, how would you compare something that happens now to a range of bars in the past (each bar, not specifically one).
[2018-06-03 03:52:58]
Sierra Chart Engineering - Posts: 104368
The range syntax is just not useful with these types of formulas.

You cannot make comparisons involving ranges. You just have to repetitively write this out with seven separate sub expressions and use those within the AND/OR functions.
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
[2018-06-03 03:57:10]
chart_warrior - Posts: 96
I can do it for my case because it's only 6 bars but what if I wanted to compare for a longer time frame? Is there a more efficient way?
[2018-06-04 10:21:46]
Sierra Chart Engineering - Posts: 104368
A more efficient way requires a specific spreadsheet function to do specifically what you need or using ACSIL to create what we would call "helper" studies:

Advanced Custom Study Interface and Language (ACSIL)
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: 2018-06-04 10:23:00
[2018-06-04 13:53:43]
Sawtooth - Posts: 3997
Try this:
=ID2.SG4>MAX(ID2.SG4[-1:-6])

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

Login

Login Page - Create Account