what wrong in the code?
n = 4
h = highest[n]
l = lowest[n]
once b = 2
v = h
if h = high[n-1] and high[n-1] > high and high[n-1] > low and (b = 1 or b = 2 ) then
v = h
b = 0
else
if l = low[n-1] and low[n-1] < low and low[n-1] < high and ( b = 0 or b = 2 ) then
v = l
b = 1
else
v = v[1]
endif
endif
return v
Hello rainerd,
You cannot use the letter “h” for a variable as it is reserved by the programming language.
Also, on line 2 and 3, you must define the chosen price to look for the highest and lowest. I modified your code a bit, here it is:
n = 4
hh = highest[n](high)
l = lowest[n](low)
once b = 2
v = hh
if hh = high[n-1] and high[n-1] > high and high[n-1] > low and (b = 1 or b = 2 ) then
v = hh
b = 0
else
if l = low[n-1] and low[n-1] < low and low[n-1] < high and ( b = 0 or b = 2 ) then
v = l
b = 1
else
v = v[1]
endif
endif
return v
Please find attached what we get for your indicator.