Average Daily Rate – ADR

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #130062 quote
    Frank
    Participant
    Junior

    Hello!

    I’m trying to code an Average Daily Rate indicator which includes a trading week of daily prices. I’d like to show it independently below the chart in a separate area.

    This is my code

    // Default Period = 7
    //ADR Average Daily Rate
    
    ADR = Average(Average[DHigh(0)-Dlow(0)]+Average[DHigh(1)-Dlow(1)+Average[DHigh(2)-Dlow(2)+Average[DHigh(3)-Dlow(3)+Average[DHigh(4)-Dlow(4)+Average[DHigh(5)-Dlow(5)+Average[DHigh(6)-Dlow(6)]]]]]])
    
    r=255
    g=0
    b=0
    
    return  ADR coloured(r,g,b) style(Line, 5) as "ADR"

    When I try to add this indicator to my chart, I get the following error:

    “A positive integer field is expected with Average”

    What am I missing here?

    Many thanks in advance for your help!

    #130063 quote
    Nicolas
    Keymaster
    Master

    Are you sure you are not confounding with an Average Daily Range? Which is the X days average or each bar range. Recent french topic (and code) about ADR: https://www.prorealcode.com/topic/probleme-sur-indicateur-range-daily/

    Frank thanked this post
    #130074 quote
    Frank
    Participant
    Junior

    Hello Nicolas,

    Thank you very much for your reply. Yes, I actually meant the “Average Daily Range”. I’ve read the post you pointed out, but I’m still not sure if using the following code (with daily prices) would give me the ADR indicator that I’m looking for, and if this is equivalent to the formula I was using before. I would appreciate if you could confirm.

    a= Average[7](Dhigh(1)-Dlow(1))
    
    Return a coloured(255,102,0) as "Average Daily Range"

    Thanks!

    #130084 quote
    Nicolas
    Keymaster
    Master

    Your formula was wrong because you were using daily price values as period?

    This last code is not good if you want to use it on a timeframe inferior to the daily one. It also includes 7 days prior to the current one, which is not included, I don’t know if you want to include the current day or not?

    Frank thanked this post
    #130089 quote
    Frank
    Participant
    Junior

    Hi Nicolas,

    I don’t know what was wrong with it, but I’m getting the error “A positive integer field is expected with Average” when I try to use it.

    I just need an indicator that returns the Average Daily Range for each trading day up to the previous one. So I’m not interested in the current one. My timeframe is 1 day.

    I’m only using daily candles, and I would like to view it below my chart, like some other pre-built indicators I’m currently using.

    Many thanks in advance for your reply.

    #130095 quote
    Vonasi
    Moderator
    Master

    If you just want an average of the last seven days ranges then the last code you posted works just fine.

    If you want the average for Mondays and the Average for Tuesdays and the average for Wednesdays then that is something totally different.

    Frank thanked this post
    #130097 quote
    Frank
    Participant
    Junior

    OK, Thank you both!

    #172756 quote
    Ganeshalove
    Participant
    Junior

    How can I display the ADR of a stock for one month on screen as I don’t need this as separate indicator.

    Could you please share the code for that? Thanks.

    #172757 quote
    robertogozzi
    Moderator
    Master

    To display whatever om screen you need an indicator.

    If you want to display it one month only, simply remove it when no more needed.

    I am not sure I understood what you mean, though.

    #172857 quote
    Ganeshalove
    Participant
    Junior

    I need to know which one is correct ADR formula for last one month ADR. I have following two codes and there is some variation comes in between these two results:

    c1 = Volume >8900000
    ADR= Average[20](Dhigh(1)-Dlow(1))
    SCREENER[c1] (ADR AS "ADR Rating")

     

    c1 = Volume >8900000
    ADR = average[20,0](range)
    SCREENER[c1] (ADR AS "ADR Rating")

     

    Moderators Edit: Post edited – please use the ‘Insert PRT Button’ when inserting code in your posts.

    #172862 quote
    robertogozzi
    Moderator
    Master

    If used ina Daily TF they are identical, but for the fact that the first one (Dhigh(1)-Dlow(1)) refers not to the last 20 periods, but to the previous 20 periods (not including today). You could use RANGE[1] to the second screener to make them match.

    If they are not used in a Daily TF, the first one correctly uses DAILY values (apart from the starting offset as explained above), while the second one refers to the RANGE according to the involved TF.

    #172918 quote
    Ganeshalove
    Participant
    Junior

    Thank you so much.

    #172921 quote
    robertogozzi
    Moderator
    Master

    In the first part of my last post I wrote “for the fact that the first one (Dhigh(1)-Dlow(1)) refers not to the last 20 periods, but to the previous 20 periods”.

    The correct version is “due to the fact that the first one (Dhigh(1)-Dlow(1)) refers not to the last 20 periods, but to the previous 20 days”.

    Sorry for any misunderstanding this may have caused.

    #173027 quote
    Ganeshalove
    Participant
    Junior

    Sorry, I didn’t understand. What’s the difference between 20 periods and 20 days? On Daily chart they both will be same? what about in hourly chart?

    #173029 quote
    robertogozzi
    Moderator
    Master

    The difference is on charts other than the daily one.

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

Average Daily Rate – ADR


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Frank @fmuratori Participant
Summary

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

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