Most Active Months – Range v2
Forums › ProRealTime English forum › ProBuilder support › Most Active Months – Range v2
- This topic has 10 replies, 2 voices, and was last updated 5 years ago by Vonasi.
-
-
01/20/2019 at 3:12 PM #89154
Manel suggested that basing my Most Active Months – Range indicator on range as a percentage of opening price would give a more useful output – especially when applied on indices where range and price historically increase with time so I have modified it slightly to do this.
You can now toggle between the original output and an output shown as a percentage of price by ticking or unticking the Percentage box.
Here is the ITF to download and import:
…and the code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120//Most Active Months - Range v2//By Vonasi//20012019//Percentage = 1if percentage thenIF openmonth = 1 THENH1 = (H1 + (((High - Low) / Open) * 100))H1Count = (H1Count + 1)ThisMonth = (H1 / H1Count)drawvline(barindex) coloured(0,0,255)ELSIF openmonth = 2 THENH2 = (H2 + (((High - Low) / Open) * 100))H2Count = (H2Count + 1)ThisMonth = (H2 / H2Count)ELSIF openmonth = 3 THENH3 = (H3 + (((High - Low) / Open) * 100))H3Count = (H3Count + 1)ThisMonth = (H3 / H3Count)ELSIF openmonth = 4 THENH4 = (H4 + (((High - Low) / Open) * 100))H4Count = (H4Count + 1)ThisMonth = (H4 / H4Count)ELSIF openmonth = 5 THENH5 = (H5 + (((High - Low) / Open) * 100))H5Count = (H5Count + 1)ThisMonth = (H5 / H5Count)ELSIF openmonth = 6 THENH6 = (H6 + (((High - Low) / Open) * 100))H6Count = (H6Count + 1)ThisMonth = (H6 / H6Count)ELSIF openmonth = 7 THENH7 = (H7 + (((High - Low) / Open) * 100))H7Count = (H7Count + 1)ThisMonth = (H7 / H7Count)ELSIF openmonth = 8 THENH8 = (H8 + (((High - Low) / Open) * 100))H8Count = (H8Count + 1)ThisMonth = (H8 / H8Count)ELSIF openmonth = 9 THENH9 = (H9 + (((High - Low) / Open) * 100))H9Count = (H9Count + 1)ThisMonth = (H9 / H9Count)ELSIF openmonth = 10 THENH10 = (H10 + (((High - Low) / Open) * 100))H10Count = (H10Count + 1)ThisMonth = (H10 / H10Count)ELSIF openmonth = 11 THENH11 = (H11 + (((High - Low) / Open) * 100))H11Count = (H11Count + 1)ThisMonth = (H11 / H11Count)ELSIF openmonth = 12 THENH12 = (H12 + (((High - Low) / Open) * 100))H12Count = (H12Count + 1)ThisMonth = (H12 / H12Count)ENDIFendifif not percentage thenIF openmonth = 1 THENH1 = (H1 + (High - Low))H1Count = (H1Count + 1)ThisMonth = (H1 / H1Count)drawvline(barindex) coloured(0,0,255)ELSIF openmonth = 2 THENH2 = (H2 + (High - Low))H2Count = (H2Count + 1)ThisMonth = (H2 / H2Count)ELSIF openmonth = 3 THENH3 = (H3 + (High - Low))H3Count = (H3Count + 1)ThisMonth = (H3 / H3Count)ELSIF openmonth = 4 THENH4 = (H4 + (High - Low))H4Count = (H4Count + 1)ThisMonth = (H4 / H4Count)ELSIF openmonth = 5 THENH5 = (H5 + (High - Low))H5Count = (H5Count + 1)ThisMonth = (H5 / H5Count)ELSIF openmonth = 6 THENH6 = (H6 + (High - Low))H6Count = (H6Count + 1)ThisMonth = (H6 / H6Count)ELSIF openmonth = 7 THENH7 = (H7 + (High - Low))H7Count = (H7Count + 1)ThisMonth = (H7 / H7Count)ELSIF openmonth = 8 THENH8 = (H8 + (High - Low))H8Count = (H8Count + 1)ThisMonth = (H8 / H8Count)ELSIF openmonth = 9 THENH9 = (H9 + (High - Low))H9Count = (H9Count + 1)ThisMonth = (H9 / H9Count)ELSIF openmonth = 10 THENH10 = (H10 + (High - Low))H10Count = (H10Count + 1)ThisMonth = (H10 / H10Count)ELSIF openmonth = 11 THENH11 = (H11 + (High - Low))H11Count = (H11Count + 1)ThisMonth = (H11 / H11Count)ELSIF openmonth = 12 THENH12 = (H12 + (High - Low))H12Count = (H12Count + 1)ThisMonth = (H12 / H12Count)ENDIFendifavg = (h1 + h2 + h3 + h4 + h5 + h6 + h7 + h8 + h9 + h10 + h11 + h12)/(h1count + h2count + h3count + h4count + h5count + h6count + h7count + h8count + h9count + h10count + h11count + h12count)c = 155if ThisMonth > Avg thenc = 255endifRETURN ThisMonth coloured (100,149,237,c) style(histogram, 2) as "Average Range", avg coloured(0,0,255) style(line,1) as "All Time Average"1 user thanked author for this post.
01/20/2019 at 4:13 PM #89161I decided to use Manel’s idea and also modify my DOWAR(OAC) Day Of Week Average Range (On Any Chart) indicator to be able to calculate each days range as a percentage of the opening price each day and then use this percentage value to calculate an average range for each day of the week.
Here is the modified ITF file:
…and the code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194//DOWAROAC Bands - Day Of Week Average Range (On Any Chart) Bands v2//By Vonasi//20012019//Multiple = 1//Offset = 1//Bands = 0//Candles = 1//StartDate = 0//Percentage = 1if opendate >= StartDate or startdate = 0 thenif opendayofweek[0] <> opendayofweek[1] thenrnge = (dHigh(1) - dLow(1))//closeif offset = 1 thenif pricetype < 1 or pricetype > 4 thenstart = close[1]endif//medianpriceif pricetype = 1 thenstart = ((rnge)/2) + dlow(1)endif//totalpriceif pricetype = 2 thenstart = (dopen(1) + close[1] + dHigh(1) + dLow(1))/4endif//typicalpriceif pricetype = 3 thenstart = (close[1] + dHigh(1) + dLow(1))/3endif//weightedpriceif pricetype = 4 thenstart = ((2*close[1]) + dHigh(1) + dLow(1))/4endifendifif percentage thenif opendayofweek[1] = 0 THENW0 = (W0 + (rnge / Dopen(1)))W0Count = (W0Count + 1)endifIF opendayofweek[1] = 1 THENW1 = (W1 + (rnge / Dopen(1)))W1Count = (W1Count + 1)endifIF opendayofweek[1] = 2 THENW2 = (W2 + (rnge / Dopen(1)))W2Count = (W2Count + 1)endifIF opendayofweek[1] = 3 THENW3 = (W3 + (rnge / Dopen(1)))W3Count = (W3Count + 1)endifIF opendayofweek[1] = 4 THENW4 = (W4 + (rnge / Dopen(1)))W4Count = (W4Count + 1)endifIF opendayofweek[1] = 5 THENW5 = (W5 + (rnge / Dopen(1)))W5Count = (W5Count + 1)endifif opendayofweek = 0 thenThisDay = (W0 / W0Count) * startendifif opendayofweek = 1 thenThisDay = (W1 / W1Count) * startendifif opendayofweek = 2 thenThisDay = (W2 / W2Count) * startendifif opendayofweek = 3 thenThisDay = (W3 / W3Count) * startendifif opendayofweek = 4 thenThisDay = (W4 / W4Count) * startendifif opendayofweek = 5 thenThisDay = (W5 / W5Count) * startendifendifif not percentage thenif opendayofweek[1] = 0 THENW0 = (W0 + (rnge))W0Count = (W0Count + 1)endifIF opendayofweek[1] = 1 THENW1 = (W1 + (rnge))W1Count = (W1Count + 1)endifIF opendayofweek[1] = 2 THENW2 = (W2 + (rnge))W2Count = (W2Count + 1)endifIF opendayofweek[1] = 3 THENW3 = (W3 + (rnge))W3Count = (W3Count + 1)endifIF opendayofweek[1] = 4 THENW4 = (W4 + (rnge))W4Count = (W4Count + 1)endifIF opendayofweek[1] = 5 THENW5 = (W5 + (rnge))W5Count = (W5Count + 1)endifif opendayofweek = 0 thenThisDay = (W0 / W0Count)endifif opendayofweek = 1 thenThisDay = (W1 / W1Count)endifif opendayofweek = 2 thenThisDay = (W2 / W2Count)endifif opendayofweek = 3 thenThisDay = (W3 / W3Count)endifif opendayofweek = 4 thenThisDay = (W4 / W4Count)endifif opendayofweek = 5 thenThisDay = (W5 / W5Count)endifendifendifif offset <> 1 thenif pricetype < 1 or pricetype > 4 thenstart = close[1]endif//medianpriceif pricetype = 1 thenstart = ((dhigh(0) - dlow(0))/2) + dlow(0)endif//totalpriceif pricetype = 2 thenstart = (dopen(0) + close[0] + dHigh(0) + dLow(0))/4endif//typicalpriceif pricetype = 3 thenstart = (close[0] + dHigh(0) + dLow(0))/3endif//weightedpriceif pricetype = 4 thenstart = ((2*close[0]) + dHigh(0) + dLow(0))/4endifendifupper = start + ((ThisDay * multiple)/2)lower = start - ((ThisDay * multiple)/2)middle = ((upper -lower)/2) + lowerif candles thendrawcandle(lower,upper,lower,upper) COLOURED(100,149,237,20) BORDERCOLOR(0,0,0,150)drawtext("-",barindex,middle) COLOURED(0,0,0)endifc = 0if bands thenc = 255endifelseupper = closelower = closemiddle = closec = 0endifRETURN upper coloured (100,149,237,c) style(line, 1) as "Upper Band", lower coloured (100,149,237,c) style(line, 1) as "Lower Band", middle coloured (100,149,237,c) style(line, 1) as "Middle Band"1 user thanked author for this post.
01/21/2019 at 8:23 PM #89286Thanks for the update Vonasi ! Much appreciated. Interesting to note that although the average and absolute vales have been increasing over the past 10 years, the %’s have been falling – as you would expect in a bull market as volatility subsides. Also highlights last October was in keeping with others historically and actually less, so helps keep perspective. In fact Feb and Dec were the actual outliers at >2x the average.
Is there a way of easily annotating what the actual current % value of each bar was in the current month on the histogram below ? That way you can visualise the outlier months in the past better.
Edit – actually there probably isn’t as it would mess up the scaling etc on the rhs
01/21/2019 at 8:40 PM #89287Is there a way of easily annotating what the actual current % value of each bar was in the current month on the histogram below ? That way you can visualise the outlier months in the past better.
That should be simple to do. I’m a bit busy at the moment with other things but I’ll try and look at it when I get some time.
01/22/2019 at 2:29 PM #89331Here you go manel – it was very simple to do but I think gives some interesting output. Tick or untick ‘EachMonth’ to turn on and off the current or historical closing range for each individual month. It works better in percentage.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128//Most Active Months - Range v3//By Vonasi//20190122//Percentage = 1//EachMonth = 1if percentage thenIF openmonth = 1 THENH1 = (H1 + (((High - Low) / Open) * 100))H1Count = (H1Count + 1)ThisMonth = (H1 / H1Count)drawvline(barindex) coloured(0,0,255)ELSIF openmonth = 2 THENH2 = (H2 + (((High - Low) / Open) * 100))H2Count = (H2Count + 1)ThisMonth = (H2 / H2Count)ELSIF openmonth = 3 THENH3 = (H3 + (((High - Low) / Open) * 100))H3Count = (H3Count + 1)ThisMonth = (H3 / H3Count)ELSIF openmonth = 4 THENH4 = (H4 + (((High - Low) / Open) * 100))H4Count = (H4Count + 1)ThisMonth = (H4 / H4Count)ELSIF openmonth = 5 THENH5 = (H5 + (((High - Low) / Open) * 100))H5Count = (H5Count + 1)ThisMonth = (H5 / H5Count)ELSIF openmonth = 6 THENH6 = (H6 + (((High - Low) / Open) * 100))H6Count = (H6Count + 1)ThisMonth = (H6 / H6Count)ELSIF openmonth = 7 THENH7 = (H7 + (((High - Low) / Open) * 100))H7Count = (H7Count + 1)ThisMonth = (H7 / H7Count)ELSIF openmonth = 8 THENH8 = (H8 + (((High - Low) / Open) * 100))H8Count = (H8Count + 1)ThisMonth = (H8 / H8Count)ELSIF openmonth = 9 THENH9 = (H9 + (((High - Low) / Open) * 100))H9Count = (H9Count + 1)ThisMonth = (H9 / H9Count)ELSIF openmonth = 10 THENH10 = (H10 + (((High - Low) / Open) * 100))H10Count = (H10Count + 1)ThisMonth = (H10 / H10Count)ELSIF openmonth = 11 THENH11 = (H11 + (((High - Low) / Open) * 100))H11Count = (H11Count + 1)ThisMonth = (H11 / H11Count)ELSIF openmonth = 12 THENH12 = (H12 + (((High - Low) / Open) * 100))H12Count = (H12Count + 1)ThisMonth = (H12 / H12Count)ENDIFNow = ((High - Low) / Open) * 100endifif not percentage thenIF openmonth = 1 THENH1 = (H1 + (High - Low))H1Count = (H1Count + 1)ThisMonth = (H1 / H1Count)drawvline(barindex) coloured(0,0,255)ELSIF openmonth = 2 THENH2 = (H2 + (High - Low))H2Count = (H2Count + 1)ThisMonth = (H2 / H2Count)ELSIF openmonth = 3 THENH3 = (H3 + (High - Low))H3Count = (H3Count + 1)ThisMonth = (H3 / H3Count)ELSIF openmonth = 4 THENH4 = (H4 + (High - Low))H4Count = (H4Count + 1)ThisMonth = (H4 / H4Count)ELSIF openmonth = 5 THENH5 = (H5 + (High - Low))H5Count = (H5Count + 1)ThisMonth = (H5 / H5Count)ELSIF openmonth = 6 THENH6 = (H6 + (High - Low))H6Count = (H6Count + 1)ThisMonth = (H6 / H6Count)ELSIF openmonth = 7 THENH7 = (H7 + (High - Low))H7Count = (H7Count + 1)ThisMonth = (H7 / H7Count)ELSIF openmonth = 8 THENH8 = (H8 + (High - Low))H8Count = (H8Count + 1)ThisMonth = (H8 / H8Count)ELSIF openmonth = 9 THENH9 = (H9 + (High - Low))H9Count = (H9Count + 1)ThisMonth = (H9 / H9Count)ELSIF openmonth = 10 THENH10 = (H10 + (High - Low))H10Count = (H10Count + 1)ThisMonth = (H10 / H10Count)ELSIF openmonth = 11 THENH11 = (H11 + (High - Low))H11Count = (H11Count + 1)ThisMonth = (H11 / H11Count)ELSIF openmonth = 12 THENH12 = (H12 + (High - Low))H12Count = (H12Count + 1)ThisMonth = (H12 / H12Count)ENDIFNow = High - Lowendifavg = (h1 + h2 + h3 + h4 + h5 + h6 + h7 + h8 + h9 + h10 + h11 + h12)/(h1count + h2count + h3count + h4count + h5count + h6count + h7count + h8count + h9count + h10count + h11count + h12count)c = 155if ThisMonth > Avg thenc = 255endifc2 = 0if EachMonth thenc2 = 255endifRETURN ThisMonth coloured (100,149,237,c) style(histogram, 2) as "Average Range", avg coloured(0,0,255) style(line,1) as "All Time Average", now coloured(0,0,0,c2) style(line,1) as "This Month"1 user thanked author for this post.
01/22/2019 at 8:25 PM #8936901/22/2019 at 9:00 PM #89370Interesting info here, am thinking more from a macro view and longer term strategies and use as a filter.
It is always a good idea to have a finger on the pulse of the bigger picture.
01/23/2019 at 4:19 PM #89467So, looking at the data in more detail for periods of exceptional vol especially, I encountered an issue with the data series. I specifically was looking for big market events at first and so chose the Dow but there is an error with the PRT chart data for the 87 crash. More specifically the intraday ranges for 19/20/21 Oct are all incorrect. People may know that on Monday the market fell 20%+ but the PRT chart only shows a range less than half that (even accounting for the opening gap from Friday close). This of course will skew any average calculations etc especially due to the magnitude of the move as it filters through and impacts future calculations.
In this particular case coincidentally as the index revisted the Monday lows in the following few days, it didn’t affect what we did here as the month ended up having the correct range – but thats just pure dumb luck (and wouldn’t be the case if we were looking at daily averages). Although granted this period is not especially important in the grand scheme of backtesting, a more important question is that – can the data set in the charts be relied upon with 100% confidence and accuracy ? Because without that, everything that we do here ends up being pretty meaningless. There may be more recent days over the last few years where data is also incorrect.
I have raised a ticket through IG about this data error, and asked them for an explanation and to of course corect it. Will let you know of the response.
01/23/2019 at 4:26 PM #89469The indicator uses HIGH – LOW to calculate range so maybe changing that to RANGE would give a little more accuracy and include any gaps – although gaps on monthly data are not going to be so important as on faster time frames.
01/23/2019 at 4:34 PM #89470The indicator uses HIGH – LOW to calculate range so maybe changing that to RANGE would give a little more accuracy and include any gaps – although gaps on monthly data are not going to be so important as on faster time frames.
Yep, that’s actually a good idea to use range if it includes gaps. But I agree, this is not really an issue on longer timeframes like monthy or even weekly. I’m a bit more concerned about accuracy of the data values in general now.
01/23/2019 at 4:44 PM #89471 -
AuthorPosts
Find exclusive trading pro-tools on