Macd Heatmap indicator

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #205737 quote
    Geons
    Participant
    Average

    Hi to all! Can someone help me to code a heatmap version of MACD ??

    Just like https://www.prorealcode.com/prorealtime-indicators/rsi-multiperiods-heatmap/

    Thanks!

    #205749 quote
    Nicolas
    Keymaster
    Master

    Why not, but the heatmap color is defined by the value of the indicator of X period (X is increased until the end of the defined scale). While an RSI has only 1 period in his setting, MACD has 3 (short term period, long term period and signal line period), here is a rough version of what can be done:

    //PRC_MACD multiperiods HeatMap | indicator
    //Plot an heatmap of the MACD range of periods
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    // --- settings
    maxscale=200 //end period of the loop
    ShortPeriod=12
    LongPeriod=26
    Step=10 //period step of the loop
    // --- end of settings
    
    iShortPeriod = ShortPeriod
    iLongPeriod = LongPeriod
    
    hh=highest[100](macd[190,200,9])
    ll=lowest[100](macd[190,200,9])
    irange=hh-ll
    
    while iLongPeriod<=maxscale do
    
    // --- indicator calculation
    osc = macd[ishortperiod,ilongperiod,9]
    // -----
    
    //result=abs((osc/pointsize)/irange)*100
     result = osc/pointsize
    
    G = (abs(result)/irange)*100
    R = 200-g
    //R = max(0,50+(200-(result-50)*12))
    //G = max(0,50+(200+(result-50)*12))
    
    drawtext("■",barindex,ilongperiod,dialog,bold,18) coloured(min(r,255),min(g,255),0)
    //drawtext("#result#",barindex,ilongperiod,dialog,bold,12) 
    
    ishortPeriod=max(shortperiod,iShortPeriod+Step) //increase indicator period for next loop iteration
    ilongPeriod=max(longperiod,ilongPeriod+Step) //increase indicator period for next loop iteration
    wend
    
    return shortperiod,maxscale//,result coloured(0,0,0,0)//,r as "r",irange as "range", osc

    In this case I’m increasing both short and long moving average at the same time and with the same step. The MACD is not bounded, so in order to color the heatmap, i’m using a scale based upon the highest and lowest values of MACD during the last 100 periods.

    #205794 quote
    Geons
    Participant
    Average

    Thank you very much Nicolas!

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

Macd Heatmap indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Geons @geons Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Geons
3 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/14/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...