Hello Everyone, my coding level is terrible but I’ve manage to get my main strategy working for proscreener. I am wondering if anyone has successfully coded a 3-test of a horizontal line (support/resistance) scanner , part of my second strategy?? I can’t see anything in the library and would love some assistance.
thanks,
adam
First you have to determine the resistance (support is just the other way round).
To do this you must choose a preferred period, say 100 bars:
[scode]
Resistance = highest[100](close)
[/scode]
now you count the number of times price (high) has hit that resistance:
[scode]
x = summation[100](high >= Resistance) >= 3
[/scode]
x will be true when Resistance has been hit at least 3 times or more.
(not tested)
Thank you, I’ll give it a try tomorrow night.
I tested it and it seems not to work correctly. This should do, instead:
p = 100
Resistance = highest[p](close)
Count = 0
FOR i = (p - 1) DOWNTO 0
IF high[i] >= Resistance THEN
Count = Count + 1
ENDIF
NEXT
SCREENER[Count >= 3](Count AS "Hits")
and this is the indicator:
DEFPARAM DrawOnLastBarOnly = true
p = 100
Resistance = highest[p](close)
Count = 0
FOR i = (p - 1) DOWNTO 0
IF high[i] >= Resistance THEN
Count = Count + 1
ENDIF
NEXT
IF Count >= 3 THEN
DRAWSEGMENT(BarIndex - (p - 1),Resistance,BarIndex,Resistance)
ENDIF
RETURN
I have this indicator that I wrote a while back that might be of interest. It calculates a level mid way through the upper and lower shadow and then checks back through p bars to see how many other shadows crossed the same level. It draws extending lines at these levels if ‘tests’ quantity of shadow crosses are detected until a new level is found to have been tested.
I might submit it to the library as I’d forgotten that I’d coded it!
defparam calculateonlastbars = 1000
p = 200
tests = 3
if barindex >=tests then
level = (high + max(open,close))/2
count = 1
draw = 0
for a = 1 to p
if close[a] > level then
break
endif
if high[a] >= level and max(close[a],open[a]) <= level then
count = count + 1
if count = tests then
startindex = barindex-a
draw = 1
break
endif
endif
next
if draw = 1 then
drawsegment(startindex,level,barindex,level) coloured(0,128,0)
lastlevel = level
else
drawsegment(barindex-1,lastlevel,barindex,lastlevel) coloured(0,128,0)
endif
level2 = (low + min(open,close))/2
count = 1
draw2 = 0
for a = 1 to p
if close[a] < level2 then
break
endif
if low[a] <= level2 and min(close[a],open[a]) >= level2 then
count = count + 1
if count = tests then
startindex2 = barindex-a
draw2 = 1
break
endif
endif
next
if draw2 = 1 then
drawsegment(startindex2,level2,barindex,level2) coloured(128,0,0)
lastlevel2 = level2
else
drawsegment(barindex-1,lastlevel2,barindex,lastlevel2) coloured(128,0,0)
endif
endif
return