Login Page - Create Account

Support Board


Date/Time: Fri, 29 Nov 2024 22:52:45 +0000



[Programming Help] - Formula to check if price has been above a level for X minutes.

View Count: 398

[2022-12-12 11:43:49]
Dean Roberts - Posts: 79
Hi
I'm trying to add a simple formula to go long if price has been above a level for x number of minutes... a simple pull back long basically.
Would this work - with AS being the level I am trying to do the check for price being above for 8 minutes (if this was a minute chart)?

AND(CROSSFROMABOVE(C3:C1000,AS3:AS1000), C3[-1]:C1000[-1]>AS3[-1]:AS1000[-1], C3[-2]:C1000[-2]>AS3[-2]:AS1000[-2], C3[-3]:C1000[-3]>AS3[-3]:AS1000[-3], C3[-4]:C1000[-4]>AS3[-4]:AS1000[-4], C3[-5]:C1000[-5]>AS3[-5]:AS1000[-5], C3[-6]:C1000[-6]>AS3[-6]:AS1000[-6], C3[-7]:C1000[-]>AS3[-7]:AS1000[-7], C3[-8]:C1000[-8]>AS3[-8]:AS1000[-8])

Is there a way of adding in a check to say price was a certain number of points above the level for that time period?

Much appreciated
Cad
[2023-01-06 19:44:29]
ForgivingComputers.com - Posts: 960
Is there a way of adding in a check to say price was a certain number of points above the level for that time period?

One approach would be a spreadsheet study and a formula that adds one to the previous value if the condition is true, and resets it to 0 if false.

Assume:
E3 = Last
AS = ID1.SG1


New Formula 1
Price above AS:
P3 =(E3>ID1.SG1@3)

New Formula 2
Count of Bars with Price Above AS:
O3 =if(P3,O4+1,0)

New Formula 3
Buy Entry - If Count >= 8 and position is flat:
K3 =AND(O3>=8,J$8=0)

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

Login

Login Page - Create Account