Support Board
Date/Time: Tue, 04 Feb 2025 05:42:03 +0000
[Programming Help] - Spreadsheet: How to look back a certain number of bars
View Count: 1157
[2020-01-01 12:20:25] |
tommartin321 - Posts: 74 |
Hello, I'm working on a Spreadsheet autotrading system and need to be able to "look back" five bars. For example, on an uptrend, I want the high of the current bar to be the highest high in the past five bars. So, the current Up bar would get a certain negative Dela number, indicating a possible reversal, but I want the high of the current bar to be the high the last five bars. I'm clear on the formula for the delta and current bar high. I just don't know how to then look back on the last five bars. Thank you, Tom |
[2020-01-01 13:40:47] |
Sawtooth - Posts: 4166 |
Try this: =C3>MAX(C4:C7) This compares the current High to the max of 4 previous Highs. This also works: =C3>MAX(C4:OFFSET(C3,4,0)) You can reference cell H2 as a user parameter, instead of modifying the formula: =C3>MAX(C4:OFFSET(C3,$H$2,0)) where H2 = 4 Date Time Of Last Edit: 2020-01-07 00:57:59
|
[2020-01-02 02:07:09] |
tommartin321 - Posts: 74 |
Thanks tomglib. The shorts seems to be working fine using the following: =C3>MAX(C4:C7) However, I can't seem to understand why the longs are generating signals when the criteria is not being met (see attached file). Longs should just be the opposite. The low of current bar should be < the low of the previous 5 bars. But you can tell from the attached picture, it's generating long signals when the previous bar has a lower low. =D3<MAX(D4:D7) Thanks, Tom |
Attachment Deleted. Longs not working.png / V - Attached On 2020-01-02 01:58:37 UTC - Size: 68.1 KB - 291 views |
[2020-01-02 02:42:11] |
Sawtooth - Posts: 4166 |
Try this: =D3<MIN(D4:D7) |
[2020-01-02 08:14:52] |
tommartin321 - Posts: 74 |
Thank you tomgilb Using MIN did the trick for the buy side. |
To post a message in this thread, you need to log in with your Sierra Chart account: