Renko Moving Average Filter Regression
- This topic has 3 replies, 3 voices, and was last updated 4 years ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › Renko Moving Average Filter Regression
Hi,
I was interested in developing a Renko moving average indicator based on Nicolas’s code here: https://www.prorealcode.com/topic/discussion-re-pure-renko-strategy/page/5/#post-122154
but with the idea of having different moving average types like the Moving Average Filter Regression: https://www.prorealcode.com/prorealtime-indicators/average-filter-regression/
It’s just that the AVG line seems a bit jerky and not smooth? Pls see image and yellow average.
Also how can you add “priceMAperiod” (because it’s part of a “once” statement) to the variables so you can adjust the moving average without having to go into the code and change it from 10 to 100 for example?
Cheers!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
//Renko Moving Average Filter Regression ///BoxSize = 100 //Average[N,M](price) //Where M can be set with any of these values, to return the specific moving average calculation: //0 = SMA //1 = EMA //2 = WMA //3 = Wilder // --- parameters // MAType = 0 Series = CustomClose // priceMAperiod = 10 // --- //-----------------------------// // SMA - Simple Moving Average // //-----------------------------// IF MAType = 0 THEN priceMAperiod = MAX(priceMAperiod, 1) AVG = Average[priceMAperiod](Series) ENDIF //----------------------------------// // EMA - Exponential Moving Average // //----------------------------------// IF MAType = 1 THEN priceMAperiod = MAX(priceMAperiod, 1) AVG = ExponentialAverage[priceMAperiod](Series) ENDIF //-------------------------------// // WMA - Weighted Moving Average // //-------------------------------// IF MAType = 2 THEN priceMAperiod = MAX(priceMAperiod, 1) AVG = WeightedAverage[priceMAperiod](Series) ENDIF //------------------------------// // WIMA - Wilder Moving Average // //------------------------------// IF MAType = 3 THEN priceMAperiod = MAX(priceMAperiod, 1) AVG = WilderAverage[priceMAperiod](Series) ENDIF //Boxsize = 100 renkoMax = ROUND(close / boxSize) * boxSize renkoMin = renkoMax - boxSize once usema=1 if usema then once priceMAperiod=10 count=0 sum=0 lastbox=0 for i = 0 to barindex do if renkomax[i]<>lastbox then lastbox=renkomax[i] count=count+1 median=((renkomax[i]+renkomin[i])/2) sum=sum+median if count=priceMAperiod+1 then sum=sum-last last=median break // endif endif next once avg=undefined if last<>last[1] then avg = sum/priceMAperiod endif endif RETURN AVG coloured(255,255,0) style(line, 2) as "Renko Mvg Ave Filter" |
Ouch! Not that easy!! Renko are not time dependent, so you can’t use a classic period (which is based on normal candlestick) and use it on the custom renko bricks i created in this code…
I did a simple MA, which is nothing less than an arithmetic average, sum all the price (which here are the renko Close) and divide the sum by the period, easy.
But if you want to make the same with other types of MA, which have very different kind of calculation, that would involve a very difficult coding. Without array, in v10.3, you should give up now.
And in v11, even with array, you don’t have to code it, because it is now possible to apply any custom indicator on renko charts.
Find exclusive trading pro-tools on