Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am aware of how to get the highest high/lowest low within the last X number of bars AND how to determine how many bars back each of those is.
What I'd like to do is find the highest high within X number of bars PRIOR to the highest high within X number of bars.
Huh, you say?
So, let's say I use MAX(High, 20)[1].
That tells me what the highest high in the last 20 bars was.
Then I use HighestBar(High, 20) and that tells me the actual value of that highest high.
Now, I want to find the highest high within the 20 bars prior to the high I just found, above.
Can anyone suggest code to do this? Or point to someone else's solution?
Thanks, in advance.
(My intention is to home in on the high/low cycles within a trading range, figuring out the width of the range and how many bars apart the highs and lows are.)
Can you help answer these questions from other members on NexusFi?
one approach would be to loop over the desired bars once you have the bar number of the highest high.
You could adjust the code in the first post here, to loop over the 20 bars to the left of the bar that returned the highest high:
Thanks, ABCTG. That will work well for the value of the previous high.
I'll also need the number of bars back that previous high occurred. I'm not much of a programmer, or I'm sure I'd see immediately how to look at all the prior closes from [1] to [barsAgo+1], but that code isn't clear to me. I'll do some research on that, unless you can offer another concise method.
you are welcome. This would be something you can accomplish with the loop from the link, too. While you loop over the bars, save the high into your variable in case it's higher than the currently found highest high and save the number of bars this high is back in another variable.
you are welcome. This would be something you can accomplish with the loop from the link, too. While you loop over the bars, save the high into your variable in case it's higher than the currently found highest high and save the number of bars this high is back in another variable.