Login Page - Create Account

Support Board


Date/Time: Sun, 28 Apr 2024 07:45:08 +0000



[Programming Help] - Return Last Two Zig Zag Reversal Values - Possible to store n number of values?

View Count: 859

[2019-07-30 16:56:28]
TapeReader - Posts: 88
Is there a way to store the prior x values without using one column for each value in a spreadsheet as is demonstrated in the following copied from the help files?


The following set of formulas can be used with the Spreadsheet Study in order to obtain the values of the three most recent Zig Zag reversals. The concept can be continued on to obtain however many Zig Zag reversal points are desired.

This example assumes that the Zig Zag study is ID1 and that the Zig Zag Input Option for Additional Output for Spreadsheets is set to Yes.

Cell O3: =IF(ID1.SG3@3 > 0, ID1.SG1@3, O4)
This sets cell O3 to the Price of the most recent Zig Zag reversal point.
Cell P3: =IF(ID1.SG3@3 > 0, O4, P4)
This sets cell P3 to the Price of the second most recent Zig Zag reversal point.
Cell Q3: =IF(ID1.SG3@3 > 0, P4, Q4)
This sets cell Q3 to the Price of the third most recent Zig Zag reversal point.
[2019-07-30 19:19:09]
Sawtooth - Posts: 3980
Is there a way to store the prior x values without using one column for each value in a spreadsheet as is demonstrated in the following copied from the help files?
Yes, use the INDEX/NMATCH function combination, like this:

(where the Zigzag study is ID1 and 'Additional Output For Spreadsheets' is set to Yes.)
In cell O3:
=ID1.SG3@3>0
This will return a 1 at every Zigzag leg.
In cell P3:
=INDEX(ID1.SG3@3:OFFSET(ID1.SG3@3,$J$30-1,0),NMATCH(1,1,O3:OFFSET(O3,$J$30-1,0),0),1)
This will return the Reversal Price to Row 3 of the most recent Zigzag leg.
In cell Q3:
=INDEX(ID1.SG1@3:OFFSET(ID1.SG1@3,$J$30-1,0),NMATCH(2,1,O3:OFFSET(O3,$J$30-1,0),0),1)
This will return the Reversal Price to Row 3 of the second most recent Zigzag leg.
An alternate way to return the Reversal Price to Row 3 of the second most recent Zigzag leg:
In cell Q3: =IF(O3,P4,Q4).
Date Time Of Last Edit: 2019-07-30 21:23:40

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

Login

Login Page - Create Account