LIN120 = LinearRegression[120](close)
GAP = CLOSE - LIN120
AVGGAP = ExponentialAverage[120](GAP)
//EMA51800 = ExponentialAverage[180](CLOSE)
LINGAPTOP = LIN120+(AVGGAP*2)
LINGAPBTM = LIN120-(AVGGAP*2)
hline = max(LINGAPTOP,LINGAPBTM)
lline = min(LINGAPTOP,LINGAPBTM)
highline = highest[120](hline)
lowline = lowest[120](lline)
C1 = max(LINGAPTOP,LINGAPBTM)<highline and max(LINGAPTOP[1],LINGAPBTM[1])=highline[1] and low < LIN120//min(LINGAPTOP,LINGAPBTM)
C2 = min(LINGAPTOP,LINGAPBTM)>lowline and min(LINGAPTOP[1],LINGAPBTM[1])=lowline[1] and high >LIN120// max(LINGAPTOP,LINGAPBTM)
if (C1) then
TRDPT = -1
elsif c2 then
TRDPT = 1
else
TRDPT = 0
endif
//indicator1, ignored = CALL "LINEAR ROLLOVER"
FOR X = 0 TO 25
IF TRDPT = 1 OR TRDPT = -1 THEN
C22 = TRDPT <> 0
BREAK
ENDIF
NEXT
SCREENER[c22]
Hi Nicolas, sorry to bother you, usually i can work this out. this screener returns no hits. yet when this code/logic is used as an indicator it displays stocks that should be returned by the screener. its only when the highest and lowest functionality is used in the code that it can’t return anything. please help! thanks
Try replacing lines 33-36 with these;
IF TRDPT[x] = 1 OR TRDPT[x] = -1 THEN
C22 = 1
BREAK
ENDIF
and add this at empty line 30:
c22 = 0
Hi Robert, very kind of you to give some time to this. Unfortunately this didnt fix it, although I see the logic in your code and I’ve taken on your changes.
the bug must be further up the code.
thanks again
The problem is the 254 lookback bar limit for ProScreener. For some mathematical reasons a period up to 85 is accepted, not greater!
I can’t figure out why, because at line 4 you use 120 periods, then another 120 (indeed that should be 119, because the first one overrides the lastof line 4) at line 13, so its 239 or 240.
Then you add a nother 1 at lines 17 (line 18 doesn’t add any period).
Then you add 26 itarations, which means a lookback of 265/266, which id too high bars, but 110 period should be accepted, because 110+110+25+1 = 246 (< 254 limit), but it isn’t. There must be some calculations I can’t spot!
I used this modified code:
p = 85
LIN120 = LinearRegression[p](close)
GAP = CLOSE - LIN120
AVGGAP = ExponentialAverage[p](GAP)
//EMA51800 = ExponentialAverage[180](CLOSE)
LINGAPTOP = LIN120+(AVGGAP*2)
LINGAPBTM = LIN120-(AVGGAP*2)
hline = max(LINGAPTOP,LINGAPBTM)
lline = min(LINGAPTOP,LINGAPBTM)
highline = highest[p](hline)
lowline = lowest[p](lline)
C1 = (max(LINGAPTOP,LINGAPBTM)<highline) and (max(LINGAPTOP[1],LINGAPBTM[1])=highline[1]) and (low < LIN120) //min(LINGAPTOP,LINGAPBTM)
C2 = (min(LINGAPTOP,LINGAPBTM)>lowline) and (min(LINGAPTOP[1],LINGAPBTM[1])=lowline[1]) and (high >LIN120) // max(LINGAPTOP,LINGAPBTM)
TRDPT = 0
if C1 = 1 then
TRDPT = -1
elsif c2 = 1 then
TRDPT = 1
endif
//indicator1, ignored = CALL "LINEAR ROLLOVER"
c22 = 0
FOR X = 0 TO 25
IF TRDPT[X] <> 0 THEN
C22 = 1
BREAK
ENDIF
NEXT
//RETURN c22 AS "Signal", X AS "#"
SCREENER[c22]
yes you’re correct, thank you again. so at least i know the data memory constraints and the lesson is i need to keep it more simple.
cheers
a