Call indicator with highest used in code
Forums › ProRealTime English forum › ProScreener support › Call indicator with highest used in code
- This topic has 4 replies, 2 voices, and was last updated 4 years ago by planbtrading.
-
-
03/24/2020 at 12:55 AM #12308712345678910111213141516171819202122232425262728293031323334353637383940LIN120 = LinearRegression[120](close)GAP = CLOSE - LIN120AVGGAP = 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) thenTRDPT = -1elsif c2 thenTRDPT = 1elseTRDPT = 0endif//indicator1, ignored = CALL "LINEAR ROLLOVER"FOR X = 0 TO 25IF TRDPT = 1 OR TRDPT = -1 THENC22 = TRDPT <> 0BREAKENDIFNEXTSCREENER[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
03/24/2020 at 5:42 AM #123090Try replacing lines 33-36 with these;
1234IF TRDPT[x] = 1 OR TRDPT[x] = -1 THENC22 = 1BREAKENDIFand add this at empty line 30:
1c22 = 003/24/2020 at 8:25 AM #123096Hi 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
03/24/2020 at 10:33 AM #123106The 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:
1234567891011121314151617181920212223242526272829p = 85LIN120 = LinearRegression[p](close)GAP = CLOSE - LIN120AVGGAP = 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 = 0if C1 = 1 thenTRDPT = -1elsif c2 = 1 thenTRDPT = 1endif//indicator1, ignored = CALL "LINEAR ROLLOVER"c22 = 0FOR X = 0 TO 25IF TRDPT[X] <> 0 THENC22 = 1BREAKENDIFNEXT//RETURN c22 AS "Signal", X AS "#"SCREENER[c22]2 users thanked author for this post.
03/24/2020 at 11:10 AM #123114yes 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
-
AuthorPosts
Find exclusive trading pro-tools on