Daily ATR range for intraday chart / history

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #43346 quote
    RoLaDay
    Participant
    Average

    Hello everyone,

    I’m already using the indicator “Daily ATR range for intraday chart” from Nicolas. It works great.

    Now I would love to do some backtesting with the code, but the code is only working for the current day. Can anyone help me to create the same indicator for history?

    Thanks a lot

    #44206 quote
    Nicolas
    Keymaster
    Master

    Would you mind posting the link or the code here please?

    #44263 quote
    RoLaDay
    Participant
    Average

    Hello Nicolas,

    this is the code:

    //PRC_Daily ATR range intraday | indicator
    //03.02.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //https://www.prorealcode.com/topic/showing-customized-daily-indicators-in-smaller-timeframes/
     
    defparam drawonlastbaronly=true
     
    // --- parameters
    ATRperiod = 20
    // ---
     
    dTR = 0
    for i = 0 to ATRperiod
     dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
    next
     
    avg = dTR/ATRperiod
    converted = round(avg/pointsize*10)/10
     
    htr = Dlow(0)+avg[1]
    ltr = Dhigh(0)-avg[1]
     
    if intradaybarindex=0 then
     begin=barindex
    endif
     
    drawsegment(begin,htr,barindex,htr) coloured(200,100,0)
    drawtext("#htr# - (D1atr: #converted#)",barindex,htr+10*pointsize,Dialog,Bold,10) coloured(200,100,0)
    drawsegment(begin,ltr,barindex,ltr) coloured(200,100,0)
    drawtext("#ltr# - (D1atr: #converted#)",barindex,ltr-10*pointsize,Dialog,Bold,10) coloured(200,100,0)
     
    return

    Thanks a lot!

    #44285 quote
    Nicolas
    Keymaster
    Master

    Here is the modified code, of course since the daily ATR changes during the day, the lines can change in a highly irregular way.

    //PRC_Daily ATR range intraday | indicator
    //03.02.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //https://www.prorealcode.com/topic/showing-customized-daily-indicators-in-smaller-timeframes/
     
    //defparam drawonlastbaronly=true
     
    // --- parameters
    ATRperiod = 20
    // ---
     
    dTR = 0
    for i = 0 to ATRperiod
    dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
    next
     
    avg = dTR/ATRperiod
    //converted = round(avg/pointsize*10)/10
     
    htr = Dlow(0)+avg[1]
    ltr = Dhigh(0)-avg[1]
     
    //if intradaybarindex=0 then
    //begin=barindex
    //endif
     
    //drawsegment(begin,htr,barindex,htr) coloured(200,100,0)
    //drawtext("#htr# - (D1atr: #converted#)",barindex,htr+10*pointsize,Dialog,Bold,10) coloured(200,100,0)
    //drawsegment(begin,ltr,barindex,ltr) coloured(200,100,0)
    //drawtext("#ltr# - (D1atr: #converted#)",barindex,ltr-10*pointsize,Dialog,Bold,10) coloured(200,100,0)
     
    return htr,ltr

    Be sure to have at least “ATRperiod” days of history for the calculation to be made correctly.

    ATR-daily-levels.png ATR-daily-levels.png
    #44340 quote
    RoLaDay
    Participant
    Average

    great that helps thanks a lot!

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

Daily ATR range for intraday chart / history


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
RoLaDay @roladay Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by RoLaDay
8 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/17/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...