monthly moving average in daily chart
Forums › ProRealTime English forum › ProScreener support › monthly moving average in daily chart
- This topic has 13 replies, 3 voices, and was last updated 5 years ago by Nuno.
-
-
11/30/2018 at 5:31 PM #86108
Hi
i created an indicator in order to simulate a 20 month moving average ((h+l+c)/3)) in a daily chart. When i use it, the indicator is ok
But when i translate it in ProScreener, the result is different
For example, for the french stock SCR (SCOR Euronext Paris), the variable ‘compteur’ used to calculate the number of month is egual to 12 instead of 20 for 20 month moving Average, so the value moving average is false
why ??? is it a proscreener limit?
here the code for the indicator
thank you for help
Nuno
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103once monthlyHigh = undefinedonce monthlyLow = undefinedonce monthlyClose = undefineddailyHigh = DHigh(1)dailyLow = DLow(1)if month <> month[1] thenmonthlyHigh = Highest[max(1,BarIndex - lastMonthBarIndex)](dailyHigh)monthlyLow = Lowest[max(1,BarIndex - lastMonthBarIndex)](dailyLow)monthlyClose = DClose(1)lastMonthBarIndex = BarIndexh20 = h19h19 = h18h18 = h17h17 = h16h16 = h15h15 = h14h14 = h13h13 = h12h12 = h11h11 = h10h10 = h9h9 = h8h8 = h7h7 = h6h6 = h5h5 = h4h4 = h3h3 = h2h2 = h1h1 = monthlyHighl20 = l19l19 = l18l18 = l17l17 = l16l16 = l15l15 = l14l14 = l13l13 =l12l12 = l11l11 = l10l10 = l9l9 =l8l8 = l7l7 = l6l6 = l5l5 = l4l4 = l3l3 = l2l2 = l1l1 = monthlyLowa20 = a19a19 = a18a18 = a17a17 = a16a16 = a15a15 = a14a14 = a13a13 = a12a12 = a11a11 = a10a10 = a9a9 = a8a8 = a7a7 = a6a6 = a5a5 = a4a4 = a3a3 = a2a2 = a1a1 = monthlyClosecompteur = compteur+1endiftp1=(h1+l1+a1)/3tp2=(h2+l2+a2)/3tp3=(h3+l3+a3)/3tp4=(h4+l4+a4)/3tp5=(h5+l5+a5)/3tp6=(h6+l6+a6)/3tp7=(h7+l7+a7)/3tp8=(h8+l8+a8)/3tp9=(h9+l9+a9)/3tp10=(h10+l10+a10)/3tp11=(h11+l11+a11)/3tp12=(h12+l12+a12)/3tp13=(h13+l13+a13)/3tp14=(h14+l14+a14)/3tp15=(h15+l15+a15)/3tp16=(h16+l16+a16)/3tp17=(h17+l17+a17)/3tp18=(h18+l18+a18)/3tp19=(h19+l19+a19)/3tp20=(h20+l20+a20)/3avg20 = (tp1+tp2+tp3+tp4+tp5+tp6+tp7+tp8+tp9+tp10+tp11+tp12+tp13+tp14+tp15+tp16+tp17+tp18+tp19+tp20)/20RETURN AVG2011/30/2018 at 6:46 PM #86110ProScreener allows only a lookback of 254 bars, so I guess 20 month by roughly 21 daily bars each yields 420 approx. which is too much!
11/30/2018 at 7:44 PM #86116thank you for your reply Roberto
so i don’t understand why some stocks have ‘compteur’ > 20 ( SEE SCREENSHOT ) and value Moving Average is ok ???
here is the proscreener code
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106timeframe(default)once monthlyHigh = undefinedonce monthlyLow = undefinedonce monthlyClose = undefinedonce compteur = 0dailyHigh = DHigh(1)dailyLow = DLow(1)if month <> month[1] thenmonthlyHigh = Highest[max(1,BarIndex - lastMonthBarIndex)](dailyHigh)monthlyLow = Lowest[max(1,BarIndex - lastMonthBarIndex)](dailyLow)monthlyClose = DClose(1)lastMonthBarIndex = BarIndexh20 = h19h19 = h18h18 = h17h17 = h16h16 = h15h15 = h14h14 = h13h13 = h12h12 = h11h11 = h10h10 = h9h9 = h8h8 = h7h7 = h6h6 = h5h5 = h4h4 = h3h3 = h2h2 = h1h1 = monthlyHighl20 = l19l19 = l18l18 = l17l17 = l16l16 = l15l15 = l14l14 = l13l13 =l12l12 = l11l11 = l10l10 = l9l9 =l8l8 = l7l7 = l6l6 = l5l5 =l4l4 = l3l3 = l2l2 = l1l1 = monthlyLowa20 = a19a19 = a18a18 = a17a17 = a16a16 = a15a15 = a14a14 = a13a13 = a12a12 = a11a11 = a10a10 = a9a9 = a8a8 = a7a7 = a6a6 = a5a5 = a4a4 = a3a3 = a2a2 = a1a1 = monthlyClosecompteur = compteur+1endiftp1=(h1+l1+a1)/3tp2=(h2+l2+a2)/3tp3=(h3+l3+a3)/3tp4=(h4+l4+a4)/3tp5=(h5+l5+a5)/3tp6=(h6+l6+a6)/3tp7=(h7+l7+a7)/3tp8=(h8+l8+a8)/3tp9=(h9+l9+a9)/3tp10=(h10+l10+a10)/3tp11=(h11+l11+a11)/3tp12=(h12+l12+a12)/3tp13=(h13+l13+a13)/3tp14=(h14+l14+a14)/3tp15=(h15+l15+a15)/3tp16=(h16+l16+a16)/3tp17=(h17+l17+a17)/3tp18=(h18+l18+a18)/3tp19=(h19+l19+a19)/3tp20=(h20+l20+a20)/3avg20 = (tp1+tp2+tp3+tp4+tp5+tp6+tp7+tp8+tp9+tp10+tp11+tp12+tp13+tp14+tp15+tp16+tp17+tp18+tp19+tp20)/20CONDITION1 = avg20 > 0SCREENER[condition1](compteur as "compteur")11/30/2018 at 8:44 PM #86122Sorry, my fault, you are not using directly a moving average, so the 254-limit does not apply in this case.
Which instruments are you applying the scrrener?
On the Daily TF?
11/30/2018 at 9:15 PM #8612412/01/2018 at 1:06 AM #86136I have tested it on many instruments and I think the problem could be that some stocks are not traded everyday and there are many “holes” (some stocks report 1 or 2 tradind days in a month) and this may lead to such odd results.
I’m afraid I cannot be of great help.
12/01/2018 at 1:00 PM #8614112/01/2018 at 1:09 PM #8614212/03/2018 at 12:07 PM #86244Sorry if I’m wrong but the indicator value compared to the one returned by the screener is not the same in any case:
1SCREENER[condition1](avg20)//(compteur as "compteur")so the 254-limit does not apply in this case.
The 254 bars limit do apply in this case. 254 candlesticks is far from enough to count 20 months on a daily timeframe, so I can’t understand why we get counter of more than 20..because if I change the “compteur” variable incrementing with:
123if day<>day[1] thencompteur = compteur+1endifthe max value I get is 255..
2 users thanked author for this post.
12/03/2018 at 10:08 PM #86269Hi Nicolas,
thank you for your reply
i made de changes about
1SCREENER[condition1](avg20)//(compteur as "compteur")but the moving average value in proscreener is incorrect because compteur < 20 (for average 20 month)
in the monthly and daily charts, moving average value is the same
About the 254 limit, i dont undestand why some value have the variable compteur > 20 . for theses stocks moving average value in Proscreener are ok (se screenshot)
what is false in my code about the variable compteur?
12/04/2018 at 8:27 AM #86282Nothing is wrong in your code, I’m trying to know why your count variable is incrementing while it is not possible due to the bars limitation.
By the way, you’ll not be able to calculate correctly your 20 months moving average in ProScreener on the daily timeframe, and that was the purpose of your initial query. Once I know more about the count issue, I will let you know.
12/04/2018 at 9:22 AM #8628512/10/2018 at 8:47 AM #8664412/11/2018 at 7:51 AM #86740 -
AuthorPosts
Find exclusive trading pro-tools on