ADR Label on chart

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #243805 quote
    gp38super
    Participant
    New

    Hi. I have a script that calculates and returns an ADR result(ADR in dollars, across the last 20 daily candles).

    Also, I’m sure there is an easier way to calculate this, but this is what I’m currently working with:

    DR=High-Low
    ADR=(DR[0]+DR[1]+DR[2]+DR[3]+DR[4]+DR[5]+DR[6]+DR[7]+DR[8]+DR[9]+DR[10]+DR[11]+DR[12]+DR[13]+DR[14]+DR[15]+DR[16]+DR[17]+DR[18]+DR[19])/20
    Return ADR

    My questions are:

    1. Is it possibly to get this result to show on the price chart in a label or bubble or similar, to appear near top of chart or near description or other, instead of regular chart type?
    2. Can I use TimeFrame to somehow show the Daily ADR as a DAILY average only, not changing with selected chart timeframe?

    Thanks

    #243828 quote
    Iván González
    Moderator
    Master

    Hi, here is another way to calculate ADR.

    defparam drawonlastbaronly=true
    dr=high-low
    adr=summation[20](dr)/20
    
    if islastbarupdate then
    drawtext("ADR=#adr#",-100,-100)anchor(topright,xshift,yshift)
    endif
    
    Return

    Here are some examples with the timeframe: https://www.prorealcode.com/documentation/timeframe-probacktest-proorder/

    #243837 quote
    gp38super
    Participant
    New

    Awesome! Thanks so much! Works perfectly!

    #243861 quote
    gp38super
    Participant
    New

    Hi. I made some adjustments to placement, font and color, but I still can’t figure out how to use Timeframe or other to always return the daily ADR regardless of chart timeframe I’m viewing.

    #243862 quote
    JS
    Participant
    Senior

    If you want to use multiple timeframes, you can place the calculation of the indicator under the desired timeframe (in this case, daily) and the output (text, plot, print) under the “Default” timeframe…

    DefParam DrawOnLastBarOnly=True
    
    TimeFrame(Daily, UpdateOnClose)
    Period=20
    DR=High-Low //or DR=Range
    ADR=Average[Period](DR)
     
    TimeFrame(Default)
    drawtext("ADR=#adr#",-100,-100)anchor(topright,xshift,yshift)
    
    Return
    #243893 quote
    gp38super
    Participant
    New

    Sorry it took me so long getting around to trying this, but I tried a couple of different ways with no success. I have slightly different position setting, but didn’t think that should make a difference.

    #243894 quote
    JS
    Participant
    Senior

    If I have understood everything correctly, you want to display the daily ADR label in the chart while the chart’s timeframe can change…
    At least, this is what the code is written for and what it also executes…
    When I load the indicator into the chart (on the price), the ADR label appears in the top right corner of the chart. Now, if I change the chart’s timeframe, for example, to 1 hour (15k units), the label remains in the same position, and the value also stays the same…

    #243896 quote
    gp38super
    Participant
    New

    Thank you. Not sure what other setting is different on my end, but I get errors when changing timeframes. I even tried changing units as well in case that made a difference. Copied and pasted also to be sure i didn’t mistype.

    #243898 quote
    gp38super
    Participant
    New

    And, it’s really great as is, it’s not like I live off that item. Just a minor house cleaning type thing if I could get it resolved.

    #243899 quote
    JS
    Participant
    Senior

    According to the error message, you are currently using:
    ADR = Average[20](High – Low)
    Which is not necessarily wrong…

    A better approach might be:
    DR = (High – Low)
    ADR = Average[20](DR)

    Iván González thanked this post
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

ADR Label on chart


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
gp38super @gp38super Participant
Summary

This topic contains 9 replies,
has 3 voices, and was last updated by JS
11 months, 3 weeks ago.

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