Divergence William%R

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #168661 quote
    minhbui
    Participant
    New

    Hello everyone,

    Can you help me for this.

    For the indicator William%R, i have the code like this

    period = 14
    hh = highest[period](high)
    ll = lowest[period](low)
    Wp = ((hhclose)/(hhll))*100
    return Wp as “Williams R percent”, 20 as “-20 level”, 80 as “-80 level”
    Can someone help me to complete with addition of divergence for William%R? (like we see in divergence RSI, each time we have a divergence,=> we will see a bar red or green to indicate that there is divergence now)
    Thank you.
    #168709 quote
    robertogozzi
    Moderator
    Master

    There you go:

    ///////////////////////////////////////////////////////////
    ONCE NumberOfBars    = 40
    ONCE WRperiods       = 14
    ONCE Distance        = 25 * pipsize
    //
    ONCE NumberOfBars    = max(1,min(999,NumberOfBars))
    ONCE WRperiods       = max(1,min(999,WRperiods))
    ONCE Distance        = Distance * PipSize
    //
    r     = 255
    g     = 0
    b     = 0
    t     = 255
    //
    src   = CustomClose
    //
    hh    = highest[WRperiods](high)
    ll    = lowest[WRperiods](low)
    WR    = ((hh-src)/(hh-ll))*-100
    //
    IF (BarIndex > (WRperiods + NumberOfBars)) THEN
    // Divergenza Ribassista
    IF (WR[1] > WR) AND (WR[1] > WR[2]) THEN
    extremum2=WR[1]
    extremum1=highest[NumberOfBars](WR)
    Prezzomax2=src[1]
    Prezzomax=Highest[NumberOfBars](src)
    IF(extremum2 < extremum1) AND (Prezzomax2 > Prezzomax[1]) THEN
    FOR  i = 1 TO NumberOfBars
    if WR[i] = extremum1 then
    zz = i
    drawsegment (barindex[1], WR[1]+Distance, barindex[zz], WR[zz]+Distance) coloured(r,g,b,t)
    endif
    next
    endif
    endif
    // Divergenza Rialzista
    IF (WR[1] < WR) AND (WR[1]<WR[2]) THEN
    extremum22 = WR[1]
    extremum11 = lowest[NumberOfBars](WR)
    Prezzomin2 = src[1]
    Prezzomin  = lowest[NumberOfBars](src)
    IF(extremum22 > extremum11) AND (Prezzomin2 < Prezzomin[1]) THEN
    FOR  i2 = 1 TO NumberOfBars
    if WR[i2] = extremum11[1] then
    zz2 = i2
    r   = 0
    g   = 0
    b   = 255
    drawsegment(barindex[1], WR[1]-Distance, barindex[zz2], WR[zz2]-Distance) coloured(r,g,b,t)
    endif
    next
    ENDIF
    ENDIF
    endif
    return WR as "Willimas R%"//, 0 as "0"

    You can change the NumerOfBars to scan a bar range, WRperiods and and Distance of lines from the price.

    If you import the ITF file you will have variables declared.

    x-4.jpg x-4.jpg MyIndicatorWR.itf
    #168781 quote
    minhbui
    Participant
    New

    Thank you so much

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

Divergence William%R


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
minhbui @minhbui Participant
Summary

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

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