A/D Volume Code from Tradinview to Prorealtime

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #173488 quote
    Brocker123Brocker123
    Participant
    Junior

    Good Morning;

    I have been studying volume in deep for some time ago and i have found this indicator that it will be great to use on Prorealtime .

    If somebody can help me to translate the code from Tradinview to Prorealtime I will be very grateful.

    Thanks so much guys.

    //@version=3
    //@author=cI8DH
    
    study("Accumulation/Distribution Volume (ADV) [cI8DH]", "ADV [cI8DH]", overlay=false, precision=0)
    
    // inputs
    height          = input(100, "Height in % (useful if overlayed on the main chart)", minval=0, maxval=100, step=5)
    base_enable     = input(false, "Baseline chart")
    aggregation     = input("smoothed MA", "Aggregation", options=["disable", "simple MA", "smoothed MA", "cumulative"])
    len             = input(14, "Moving average length", minval=1) // EMA27 = SMMA/RMA14 ~ lunar month
    price_enable    = input(false, "Show money volume (price x volume)")
    
    // calculations
    ch              = change(close)
    AD_ratio        = nz(ch/tr(true)) // 'True Range' fixes issues caused by gaps in price
    base            = if base_enable
        sign(AD_ratio)
    else
        1
    vol             = if price_enable
        volume*hlc3
    else
        volume
    base_price_vol  = base*vol
    base_AD         = base_price_vol*abs(AD_ratio)
    
    // aggregation
    ma(s) =>
        if aggregation!="disable"
            out = if aggregation=="simple MA"
                sma(s,len)
            else 
                rma(s,len)
        else
            na
    MA_base_price_vol = if aggregation=="cumulative"
        cum(sign(AD_ratio)*vol)
    else
        ma(base_price_vol)
    MA_AD = if aggregation=="cumulative"
        cum(AD_ratio*vol)
    else
        ma(base_AD)
    
    // plot
    plot(aggregation=="cumulative" ? na : 0, "Zero line", #88888888)
    plot(aggregation=="cumulative" ? na : base_price_vol   , "Volume"    , ch>0?#65D25B44:ch<0?#FE6B6944:#888888ff, style=columns)
    plot(aggregation=="cumulative" ? na : base_AD          , "A/D Volume", ch>0?#92df8bff:ch<0?#fe9695ff:na, style=columns)
    plot(MA_AD, "A/D moving average", #4477ffff)
    plot(MA_base_price_vol, "Volume moving average", #ff9900ff)
    plot(height==100 or aggregation=="cumulative" ? na : (100.0/height)*base_price_vol, "Dummy", na, editable=false)
    #184892 quote
    daxtrader3daxtrader3
    Participant
    Junior

    Dear Brocker,

    Has you made it possible to make the code work in pro real time?

    Thanks Tom

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

A/D Volume Code from Tradinview to Prorealtime


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Brocker123 @brocker123 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by daxtrader3daxtrader3
4 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/12/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...