Distribution of Index indicator bug fix

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #160934 quote
    Vonasi
    Moderator
    Master

    When I developed the Distribution of Index indicator that can be found in the library I only had v11 end of day data and it has come to light that on live data it continuously updates the distribution chart tick by tick leading to an incorrect chart being displayed.

    I have fixed the bug and suggest that anyone who uses v1.1 updates to v1.2.

    ITF file attached.

    //Distribution of Index v1.2
    //PRT v11 onwards
    //By Vonasi
    //Date: 20210210
    
    //p = 14                // Period used in indicator
    //k = 3                 // K% setting for stochastic
    //d = 9                 // Period used for signal line
    //RSIndex = 1           // Select RSI
    //Stoch = 0             // Select Stochastic
    //WilliamsR = 0         // Select Williams%R
    //ADXindex = 0          // Select ADX
    //SignalLine = 1        // Turn on/off display of signal line
    //StartDate = 19950101  // Date to start analysis from. Zero = all data
    
    if date >= startdate then
    if islastbarupdate then
    $lastopen[0]=open
    endif
    
    p = max(1,p)
    k = max(1,k)
    d = max(1,d)
    
    once signal = undefined
    
    if RSIndex or (not Stoch and not WilliamsR and not ADXindex) then
    indicator = rsi[p](close)
    endif
    
    if Stoch then
    indicator = stochastic[p,k](close)
    endif
    
    if WilliamsR then
    indicator = williams[p](close)+100
    endif
    
    if ADXindex then
    indicator = ADX[p]
    endif
    
    if signalline then
    signal = average[d](indicator)
    endif
    
    rindicator = round(indicator)
    
    if open<>$lastopen[0] then
    for a = 1 to 100
    if rindicator = a then
    $perc[a] = $perc[a]+1
    maxval = max(maxval,$perc[a])
    break
    endif
    next
    endif
    if islastbarupdate then
    for a = 1 to 100
    thisperc = round(($perc[a]/maxval)*100)
    if rindicator = a then
    drawpoint(barindex+thisperc+5,a,3) coloured(0,0,255)
    drawtext("#thisperc#%",barindex+115,a,sansserif,bold,14) coloured(0,0,128)
    endif
    r = 255
    g = 0
    if thisperc >= 25 then
    r = 128
    g = 0
    endif
    if thisperc >= 50 then
    r = 0
    g = 255
    endif
    if thisperc >= 75 then
    r = 0
    g = 128
    endif
    drawrectangle(barindex+5,a,barindex+thisperc+5,a) coloured(r,g,128)
    next
    
    for a = 1 to 4
    if ADXindex then
    drawtext("ADX #p# = #rindicator#",barindex+5,108,sansserif,bold,14) coloured(0,0,128)
    break
    endif
    if WilliamsR then
    drawtext("Williams%R #p# = #rindicator#",barindex+5,108,sansserif,bold,14) coloured(0,0,128)
    break
    endif
    if Stoch then
    drawtext("Stochastic #p##k##d# = #rindicator#",barindex+5,108,sansserif,bold,14) coloured(0,0,128)
    break
    endif
    if RSIndex or (not Stoch and not WilliamsR and not ADXindex) then
    drawtext("RSI #p# = #rindicator#",barindex+5,108,sansserif,bold,14) coloured(0,0,128)
    break
    endif
    next
    endif
    endif
    
    return 0 coloured(0,0,0,0) as "Line",108 coloured(0,0,0,0) as "Line",indicator as "Indicator",signal style(dottedline) as "Signal"
    
    willi thanked this post
    Distribution-of-Index-v1.2.itf
    #166052 quote
    snucke
    Participant
    Veteran

    Hey Vonasi

    is it possible you can help me add % of moves in the market to the indicator?

    #166060 quote
    Vonasi
    Moderator
    Master

    I did start coding something that showed distribution of price movements for a candle shown on a price chart but it requires some auto-scaling improvements before it is finished. At the moment I am not coding due to other commitments (plus I destroyed my keyboard with a cup of tea and my temporary replacement is horrible to type on. Also the results of Brexit are making getting a UK layout replacement keyboard delivered to Greece rather more challenging than it should be!)

    Have you seen these other indicators that I coded for distributions?

    Price Rating and Distribution

    Distribution of Returns PRTv11

    #166102 quote
    snucke
    Participant
    Veteran

    https://www.prorealcode.com/prorealtime-indicators/distribution-of-returns-prtv11/

    looks interesting, not really sure how to make use of it? do you have any suggestion on how to use it? or any place one can learn more about it?

    did some searching and could not really get my head around how to interpret it to a strategy

    #166104 quote
    Vonasi
    Moderator
    Master

    I can’t tell you how to use it in a strategy. Distribution curves really just tell us how often an event has happened in the past and that can tell us the probability of it happening in the future. Also if we can see where we are on the curve at the moment then we can see how extreme recent price movements have been which can help us decide how likely a reversal is.

    #181939 quote
    jmf125
    Participant
    Senior

    For some reason the indicator is not displaying the bar chart, any idea ?

    #181952 quote
    robertogozzi
    Moderator
    Master

    It won’t display on any chart, as its scale doesn’t not match prices. It must be installed BELOW the chart.

    ON you chart you can spot it, but, say on DAX, it’s around level 50, while prices are at about 16100, so you need to use your mouse to reach 50 or shrink the chart about 300 times (making both bars and the indicator almost flat lines).

    #181978 quote
    jmf125
    Participant
    Senior

    Sorry I should have been more precise. I does not display below the chart.

    What I am getting for the bar chart is N/A see attached picture

    Capture-2.png Capture-2.png
    #182121 quote
    robertogozzi
    Moderator
    Master

    It’s because of the second FOR…NEXT iteration the one after if islastbarupdate then, if you set it to max 20 it’ll always work (still I couldn’t see any percentage, but there’s no error). With RSI that limit can be 50 and 40 with Williams’R, but ADX requires 20 max.

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

Distribution of Index indicator bug fix


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

This topic contains 8 replies,
has 4 voices, and was last updated by robertogozzi
4 years, 2 months ago.

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