Hello,
I am new to this part of the forum in English as I must confess I didn’t read beyond the French part until now that I discover Nicolas is helping us all in no less than 5 different languages (tha’s impressive Nicolas!). I will pay more attention to the English forum too from now on.
If I understand correctly your problem, I am guessing the part you might not know yet about PRT language is the meaning of the [n] syntax might change depending on which word it is used with. So first a bit more about this. Apologies if I’m wrong and you already knew all of this:
Example 1: when you use a PRT specific term refering to several bars at the same time, like “lowest” + a number in bracket (say, lowest[6]) then yes you are refering to all the latest 6 bars to find the lowest among those.
Example 2: if you use a PRT specific term refering to only one bar, like “low”, then the number in brackets is not a total number of recent bars here, but it is the rank of the previous single bar you are looking at, for example low[1] or high [1] (which you used in your code) are refering to the previous bar, but low[4] or high[4] would have refered to bar number 4 in the past with previous one being 1, etc…
Now, when you use the [n] syntax for a variable defined by yourself, such as hh1[n], then you are not looking at what happens for all the latest n bars like in example 1, you are looking at the value of your hh1 variable for the bar numbered “n” in the past like in example 2 (starting from current bar being number zero).
From there, you should see that Nicolas did indeed answer in principle when he suggested for example to look at lh1 [1] (value of lh1 for previous bar) and lh2[10] (value of lh2 for 10th bar in the past starting from current bar being number zero)
Consequently, if you want to to find a way of coding highest[7 to 40](high), I would look at values between 7 and 40 in the past by using Nicolas’ suggestion as follows: pick hh2[6] so that you succesfully exclude the latest 6 bars number zero, 1,2,3,4,5 and also define hh2 as highest[34](high) so that from 7th bar (number 6) you don’t go further than 40th bar (number 39). If you kept highest[40](high) then hh2[6] would reach as far as 46th bar, and from what I understand, you don’t want that, you want no more than 40 in the past (from zero to 39). So I would try with:
hh1=highest[6](high)
hh2=highest[34](high)
c5= (hh1>=hh2[6])
That’s how I’d do it, and same thing for ll, hl, lh…
But considering you seem to want to look at a start from previous bar rather than from current bar, one last point I’d make if that’s important to you (meaning you want in fact to exclude 7 bars and not 6, or exclude current bar + 6 past ones if you will) : you could use c5=(hh1[1]>=hh1[7]) instead of my c5=(hh1>=hh1[6]) above. That choice of course is up to you and what you want to achieve with your code. Personnally, I like to see “live” result in current bar in my codes, and choosing to wait for current bar to close to see its frozen result, that’s why I went with c5=(hh1>=hh1[6]) first.