I am trying to construct a strategy that finds stocks that have hit a 7-day low, but when I test, it finds no stocks over several years, so I must not be coding the idea correctly. Here are the lines as I have written them:
Close < LLV(Close, 6); //close is at 7-day low
Close > HHV(Close, 6); //close is at 7-day high
I can't see what is wrong with these. Thanks.
@JohnHoward I think you need to review this post,
Continuing the discussion from
How do I learn AFL?:
Many new users with zero programming experience struggle when their formula works incorrectly. Here are few hints that everyone should use to make finding errors easier.
First of all: you have to get insight into what the formula is actually doing, not what you think it does.
Typically new user has no idea what is happening inside. Pretty often you make an assumption that things work one way but in fact they work differently. Do not assume t…
For example, run an exploration and see what your code is generating compared to what you are actually attempting to achieve.
May I suggest that you review the proper use of the functions,
Calculates the lowest value in the ARRAY over the preceding periods ( periods includes the current day)
Try something like this (I'm on my phone so can't properly check if this works),
SevenBarLow = Close < Ref( LLV(Close, 6), -1);
another possible variation
Close == LLV(Close, 7)
Function LLV returns the lowest value of the last "period" bars , included the current one. For this reason a condition like:
Close < LLV(Close, 6);
return always false, because a number can not be
strictly lower than it self.
2DD, Thank you. I see the error.
Thank you, that's what I was not seeing.
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.