Renko Moving Average Filter Regression

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #127814 quote
    Bard
    Participant
    Master

    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!

    //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"
    
    renko-ave.png renko-ave.png
    #127866 quote
    Nicolas
    Keymaster
    Master

    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.

    Bard thanked this post
    #127916 quote
    Bard
    Participant
    Master

    Thanks, glad I didn’t copy and paste and then edit all the different moving average types in anticipation of your “code fix” for the above indicator! Is v11 out yet?

    #130216 quote
    Bel
    Participant
    New

    Shame we can’t put indicators on IG 10.3 versions even though 11 is out already but they seem to do nothing to implement it. I’m interested in the same as Brads as well. Seems other platforms had these options for ages.

     

    Regards,

    Bel.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Renko Moving Average Filter Regression


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bard @brad Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by Bel
5 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 04/24/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...