How would you create a Mov Ave Distribution Histogram?

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

    Hi

    I was reading Shay Campbells’ E-Mini Swing Trading System: http://timingcharts.com/articles/2017/10/20/e-mini-sp-500-swing-trading-system/
    where he uses a technique to enter the market based on pull backs of the price based upon a Moving Average Distribution indicator: Pls see image.

    “Using a very short moving average of median price does a good job of defining a usable equilibrium point.  A distribution can then be calculated around that equilibrium by subtracting the equilibrium point from the market price.

    To normalize these readings for volatility, this result is then divided by the recent daily range of price.

    Buy Signal=  Trend Direction is Up (6 to 9 month Mov Ave) and the MA Distribution registers a significant Pullback, i.e, negative value.

    Sell Signal=  Trend Direction is Down and the MA Distribution registers a significant Pullback, i.e, positive value.”

    I was attempting to re-create that indicator but wondered how as I’m not a coder. My attempt based on other indicators is not working but I hope I’m thinking along the right lines.. unless I have over complicated it?

    Cheers

    DEFPARAM CalculateOnLastBars = 100
    Period = 20
    MAPeriod = 20
    ATRPeriod = 20
    r = 0
    g =0
    
    Ave = Average[MAPeriod](MedianPrice)
    ATR =  AverageTrueRange[ATRPeriod](Close)
    
    S = 0
    FOR i = 1 TO Period
    TP = TotalPrice[i]
    Dist = (TP - Ave)/ATR > 0      //  1 = TP > Ave
    
    IF Dist = 0 THEN
    Dist = (TP - Ave)/ATR < 0 * -1 // -1 = TP < Ave
    ENDIF
    S = S + Dist //Sum up all Dist’s
    
    NEXT
    Dist = Dist*(s) //Histogram
    Ave  = Average[MAPeriod](MedianPrice) //Signal Line
    
    
    Return Dist coloured(r,g,0) style(histogram) as "Moving Average Distribution", Ave AS "Signal Line", 0 AS "Zero"
    
    #92798 quote
    Nicolas
    Keymaster
    Master

    this result is then divided by the recent daily range of price.

    daily range is not the ATR, it is called the ADR (an average of the last X days range). “Recent” would mean how many period?

    #92840 quote
    Bard
    Participant
    Master

    Oh, right, thanks. In the article Shay doesn’t specify exactly other than to say recent. It would make sense to keep the ADR in relation to the moving average for the distribution, no? He writes:

    The MA Distribution tells us what’s happening in the very short term using just a couple weeks of data.

    So I guess 20 days?

    #92863 quote
    Nicolas
    Keymaster
    Master

    Ok, I took this value in the below code, you can change it of course. The indicator makes sense since it finds easily the pullbacks when you are in a well established trend.

    //PRC_MovingAverage Distribution | indicator
    //05.03.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    // --- settings
    ShortMAPeriod = 20
    ADRperiod = 20
    // --- end of settings
    
    //compute ADR
    sum=0
    for i = 0 to ADRperiod-1 do
    sum=sum+(dhigh(i)-dlow(i))
    next
    adr=sum/ADRperiod
    
    shortMA=average[ShortMAPeriod](medianprice)
    diff=medianprice-shortMA
    
    MAD=(diff*100)/adr
    
    return MAD style(histogram)

    If you find it correct according to the original description, I will put it into the library for everyone to benefit from this concept.

    Bard thanked this post
    #92887 quote
    Bard
    Participant
    Master
    #92891 quote
    Nicolas
    Keymaster
    Master

    😆

    The indicator is now available in the library: Moving Average Distribution

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

How would you create a Mov Ave Distribution Histogram?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bard @brad Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Nicolas
6 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/03/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...