add divergence to indicator

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #197715 quote
    ullle73ullle73
    Participant
    Senior

    A while ago i found this indicator, looked everywhere for this with a divergence. Is it possible to get help adding it? šŸ™‚

     

    tw = high - max(open, close)
    bw = min(open, close) - low
    body = abs(close - open)
    
    if volume then 
    if open<=close then
    deltaup = volume*(0.5 * (tw + bw + (2 * body)) / (tw + bw + body))
    endif
    
    if open > close then
    deltadown = volume*(0.5 * (tw + bw + (2 * body)) / (tw + bw + body))
    endif
    endif
    
    if close >= open then
    delta= deltaup
    else
    delta= -deltadown
    endif
    
    cumdelta = cumsum(delta)
    
    drawcandle(cumdelta[1],max(cumdelta, cumdelta[1]),min(cumdelta, cumdelta[1]),cumdelta)
    return
    #199904 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Try this one (add it to your chart, like MACD, then set it to be plotted as a histogram):

    //DEFPARAM CalculateOnLastBars = 5000
    //ONCE Periods = 50
    srcH = high   //or CLOSE
    srcL = low    //or CLOSE
    // indicator BEGINNING
    tw = high - max(open, close)
    bw = min(open, close) - low
    body = abs(close - open)
    if volume then
    if open<=close then
    deltaup = volume*(0.5 * (tw + bw + (2 * body)) / (tw + bw + body))
    endif
    if open > close then
    deltadown = volume*(0.5 * (tw + bw + (2 * body)) / (tw + bw + body))
    endif
    endif
    if close >= open then
    delta= deltaup
    else
    delta= -deltadown
    endif
    cumdelta = cumsum(delta)
    //drawcandle(cumdelta[1],max(cumdelta, cumdelta[1]),min(cumdelta, cumdelta[1]),cumdelta)
    Cmax = max(cumdelta, cumdelta[1])
    Cmin = min(cumdelta, cumdelta[1])
    // indicator END
    //
    IF BarIndex > Periods THEN
    Diverg = 0
    HHbar = HighestBars[Periods](srcH[1])
    LLbar = lowestBars[Periods](srcL[1])
    // BULLISH divergence
    IF high[HHbar] > high THEN
    IF Cmax[HHbar] <= Cmax THEN
    Diverg = 1
    ENDIF
    ENDIF
    //
    // BEARISH divergence
    IF low[HHbar] < low THEN
    IF Cmin[HHbar] >= Cmin THEN
    Diverg = -1
    ENDIF
    ENDIF
    //
    ENDIF
    x = Diverg
    IF Diverg = Diverg[1] THEN
    x = 0
    ENDIF
    return x AS "Divergence",0 AS "Zero"
    Nicolas thanked this post
    CumDelta-Divergences.itf
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTimeā„¢ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

add divergence to indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
ullle73 @jonas_rydqvist Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
4 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/22/2022
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...