Login Page - Create Account

Support Board


Date/Time: Fri, 22 Nov 2024 16:43:39 +0000



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

View Count: 1031

[2019-07-30 16:56:28]
TapeReader - Posts: 89
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: 4118
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
[2024-10-07 01:48:45]
User48838 - Posts: 120
I know this is an old post but i wasnt able to get the formula to work so I improvised wityh the attached pictures. ID1 is the zigzag study, same as above
image2024-10-06_21-44-15.gif / V - Attached On 2024-10-07 01:48:30 UTC - Size: 5 KB - 23 views
image2024-10-06_21-42-43.gif / V - Attached On 2024-10-07 01:48:37 UTC - Size: 4.26 KB - 18 views
[2024-10-07 04:25:38]
Sawtooth - Posts: 4118
Here is another way:
Spreadsheet Example Formulas and Usage: Return Last Two Zig Zag Reversal Values

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

Login

Login Page - Create Account