Login Page - Create Account

Support Board


Date/Time: Fri, 22 Nov 2024 22:09:25 +0000



[Programming Help] - How to wait for 2 new bars before calculating a value in the Spreadsheet alert study?

View Count: 124

[2024-09-18 20:35:18]
C_Money - Posts: 64
So I'm trying to use a custom ZigZag to give me higher highs and lower lows etc and grab the highest and lowest of those values in X bar range.

In column "O" I have
=ID35.SG6@3
returning a value between 0 and 4. When I get any value thats greater than or equal to 1, I want to wait for another 2 bars before getting the highest high and lowest low of a 5 bar range and plot the highest high in column "T" and the lowest low in column "U".

At the moment all I know how to do is get the immediate previous 5 highs and lows which.. is ok but not quite what I'm looking for.
[2024-09-18 21:18:21]
John - SC Support - Posts: 36238
We are not sure how you are using Column O, but to look at a value from 2 bars prior to the current bar, you would need to reference row 5 rather than row 3. For instance, to look at the value of your ZigZag 2 bars back your formula would look like the following:
=ID35.SG6@5
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2024-09-19 22:13:34]
C_Money - Posts: 64
Column O just represents whenever an HH,LL,HL,LH gets printed and they're denoted by numbers 1 - 4.

I was really just trying to create a 5 bar range where anytime there was a 1 - 4, I would capture the lows and highs 2 bars behind and 2 bars ahead of it and then record the highest high and lowest low, and then clamp the result so it doesn't exceed a certain value. X3 would have the lowest low and Y3 would have the highest high and I'd plot those with the subgraph.

I tried referencing row 5 but then the 5 bar range I was looking for would be in the wrong place. (let it be said I always hated excel and I'm terrible with numbers..)

The closest I got for the highs was:
=IF(AND(O3>=1, O3<=4), MAX(OFFSET(ID0.SG2@3, 0, 0, 5, 1)), "")
and for the lows:
=IF(AND(O3>=1, O3<=4), MIN(OFFSET(ID0.SG3@3, 0, 0, 5, 1)), "")

I was thinking if I could write in both formulas in X5 and Y5 (and reference X3 and Y3), the above would work but the formulas don't copy down from those rows and when a new bar prints, the formula doesn't stay in those cells.
Date Time Of Last Edit: 2024-09-19 22:20:34
[2024-09-20 13:50:43]
John - SC Support - Posts: 36238
Since you are looking for a 5 bar range, we assume that you really are wanting to look at the value 2 bars back from the current bar, that way you have the 2 bars ahead and you can then look back 2 bars. To get the Highest High over those 5 bars entering the following formula in row 3 of a formula column:
=IF(ID1.SG2@5 <> 0, MAX(ID0.SG2@3:ID0.SG2@7), 0)

Where ID1 is the ID of the Zig Zag study and SG2 is the subgraph that has the values from 0 - 5.

We leave it to you to setup the Minimum situation.
For the most reliable, advanced, and zero cost futures order routing, use 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