Login Page - Create Account

Support Board


Date/Time: Mon, 29 Apr 2024 00:42:38 +0000



Shortcut for Alert Requiring Multipe Prior Bars in MAX Formula

View Count: 1397

[2016-09-06 21:13:00]
bhetterick - Posts: 8
I am trying to create an alert using Color Bar Based On Alert Condition that colors the bar when a study subgraph current bar is the max of the most recent 20 bars of the subgraph.

I tried writing the alert condition similar to how one would do it in a spreadsheet (i.e. =ID22.SG1=max(id22.SG1:id22.SG1[-19]) but cannot get it to work as written.

The trouble seems to be when trying to incorporate other studies/subgraphs into the formula, because a formula like =C=MAX(C:C[-19]) does work.

How would one write this formula to refer to a different study and subgraph when trying to find the MAX of a series of prior bars of the subgraph? Thanks for your help.
[2016-09-06 21:47:21]
Sawtooth - Posts: 3982
The syntax for Simple Alerts is different than for spreadsheets:
The current bar in Simple Alerts is referenced:
=ID22.SG1[0] where the [0] is optional for 0 only.
The current bar in a spreadsheet is referenced:
=ID22.SG1@3 where 3 is row 3.

So the spreadsheet formula would be:
=MAX(ID22.SG1@3:ID22.SG1@22)
Date Time Of Last Edit: 2016-09-06 21:47:40
[2016-09-06 21:59:10]
bhetterick - Posts: 8
Thanks, but I am not using a spreadsheet study, but rather am trying to get the proper syntax for a MAX formula for use in the alert tab of the Color Bar Based On Alert Condition study.
[2016-09-06 22:22:57]
Sawtooth - Posts: 3982
=ID22.SG1=max(id22.SG1:id22.SG1[-19])
This formula does color bars for me, using the Color Bar study.
What bars are you expecting to be colored?
[2016-09-06 23:04:56]
bhetterick - Posts: 8
My bars actually color, but when I dig into the data, it is not coloring the correct bars. For example, if you have a study volume called ID1 with SG1 being volume, and add a Color Bar Based On Alert Condition study with the formula =ID1.SG1=Max(ID1.SG1:ID1.SG1[-19]), you will get bars that color but if you check closely you will see that it is coloring bars other than just the current bar being the max bar of the most recent 20 bars.
[2016-09-07 00:01:31]
Sawtooth - Posts: 3982
OK, the MAX function cannot do a range in Simple Alerts. (It works in spreadsheets, however.)
The : is the same as a , when used in Simple Alert formulas, so it is only comparing the current bar to the -19 bar, nothing in between.

Here is a workaround:
-Add the Highest High/Lowest Low Over N Bars study
-Set the Based On to the Volume study (or any study of interest)
-Set the Chart Region to the Volume study (or any study of interest)
-Set the length to 20
-Set the Input Data High to the desired subgraph

In the Color Bar study, reference the Highest High study with a formula like this:
=AND(ID2.SG1[-2]>ID2.SG1[-1],ID2.SG1>ID2.SG1[-1])
where ID2 is the Highest High study.

This will color the first price bar where the Volume is the highest in the last 20 bars.
[2016-09-07 06:20:09]
Sierra Chart Engineering - Posts: 104368
Ranges are not supported at all with Simple Alerts. None of these formulas are considered valid.

You would have to use something like MAX(ID1.SG1, ID1.SG1[-1], ID1.SG1[-2])

For ranges you would have to use the Spreadsheet System/Alert study instead:
https://www.sierrachart.com/index.php?page=doc/SystemsAlerts.php
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: 2016-09-07 17:24:33
[2016-09-07 10:35:27]
bhetterick - Posts: 8
tomgilb, your highest high study suggestion is a great one. Very simple and quite effective. Many thanks for helping me on this.....very much appreciated.

Although the Sierra Chart Engineering suggested using the spreadsheet alert system, I have tried using the spreadsheet study in the past.....although it can meet more complicated condition requirements for formulas, I have never been able to successfully use the spreadsheet study function without a severe performance issue....it simply is too slow bogging down my machine. If one has multiple chartbooks or charts open at once, it becomes impractical to use due to being so slow. Perhaps I am not utilizing the spreadsheet study correctly, but lack of speed always seems to become the issue with it for me that requires seeking other alternatives to accomplish the task.
[2016-09-07 10:58:09]
Sierra Chart Engineering - Posts: 104368
The suggestion given by the user is a good one.

However, if you use the Spreadsheet Study and want to not have any performance impact or keep it very minimal, you could reduce the Number of Rows input:
Spreadsheet Study Inputs
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
[2016-09-07 14:47:50]
Sawtooth - Posts: 3982
I have never been able to successfully use the spreadsheet study function without a severe performance issue
Significant performance improvements were made to New Spreadsheets in v1358. If you haven't tried them since before this version, you should give them another try when you need the additional functionality.

As Support says, you can minimize performance impact by keeping the Number of Rows to a minimum. If you need to see further into the past than the Number of Rows setting, you can scroll the chart into the past and start a Replay Chart, then pause it.

You could use one same-named spreadsheet for all charts in a chartbook, since by default each chart will output to its own sheet. In this scenario, the Chart Data Output Sheet Number needs to be set to 0.
If the formulas are the same for some or all sheets, you can have one sheet set as the master. This is done with the Formula Source Sheet Number setting. Otherwise, the Formula Source Sheet Number should be set to match the chart #.

If you have multiple chartbooks open concurrently, the spreadsheet name needs to be unique to each chartbook.

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

Login

Login Page - Create Account