Good day, This is my first time trying….
I want to create an indicator that could identify:
- The highert point in the last X bars then
- From that point of the highest bar, to the current bar, I would like to calculate the second highest bar.
But I constantly get an error message: “un parametre de type entier positif est attendu avec highest”
Here is the code, and I do not understand the reason, as the defenition is a full number??? Could anyone help?
bars = 70
Y1 = highest[bars] (high[1])
if high <Y1 or high [1]<Y1 then
for i = bars downto 1 do
if high [i] = Y1 then
X1 = i-1
DRAWTEXT("#X1#", barindex [X1], high [x1])
break
endif
next
Y2 = highest[X1] (high[1])
for n = X1 downto 0 do
if high [n] = Y2 then
X2 = n
DRAWTEXT("#X2#", barindex [n], high [n])
break
endif
next
endif
return
Hello, moderation messages :
- you posted in English in french forum, please see rules in yellow box below about choosing the right forum. No need to repost we’ll move this topic now
- you posted code without formatting it, please see image attached to locate the “insert PRT code” button as this is your first time. Again no need to repost, we’ll reformat your code in above message now
Your first “for to next” loop ending with i=1, x1=i-1 will be =0 when i=1, and the error message “entier positif” (positive integer) for X1 in highest[x1](…) means X1 has to be at least 1, not 0… so either make sure X1 can’t be zero, or use something bigger than X1 with highest
Thanks you for pointing this out! It was a great help