Hello,
I made a question in this post in the library, but i guess it’s hard to see there, maybe someone can help me here:
Average (Daily) Range
Hello, I wanted to create a percent ADR based on this indicator, so I wrote this code that IMO it looks ok:
// AVERAGE DAILY RANGE PERCENTAGE
PMAXAVG = average[p](high)
PMINAVG = average[p](low)
PAVG = average [p] (close)
ADRP = (PMAXAVG – PMINAVG)/PAVG*100
return ADRP as “Average Daily Range Percent”
However, when I use it, it doesn’t seem to give out correct values as it is giving me a higher value than the ATRP described in this post for the same 20 daily periods:
Average True Range Percent (ATRP)
From my understanding of ADRP and ATRP, ADRP should always be lower than ATRP as it doesn’t include gaps.
Can someone help me out? thanks
Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Thank you 🙂
Try changing line 6 to:
ADRP = ((PMAXAVG – PMINAVG)/PAVG)*100
Thanks a lot, however that doesn’t seem to change the formula, it gives the same result.
With 90% of stocks, it seems that both the ATRP and the ADRP I posted give the correct value. But with some of them ADRP is bigger. With SNDL for instances. Any clue?
Try comparing the two with this code:
// AVERAGE DAILY RANGE PERCENTAGE
p = 14
ATRP = (averagetruerange[p](close)/close)*100
PMAXAVG = average[p](high)
PMINAVG = average[p](low)
PAVG = average [p] (close)
ADRP = (PMAXAVG - PMINAVG)/PAVG*100
return ADRP as "Average Daily Range Percent",ATRP as "Average True Range Percent"
Moreover, the above code doesn’t skip gaps.
Hi,
This code you posted gives as a result both the ADRP and ATRP i posted in a single indicator.
However, the issue is still the same. In most stocks the ATRP is higher than the ADRP, but in some the ADRP is higher. From my understanding of ADRP and ATRP that should be impossible as ATRP includes gaps and ADRP doesn’t, hence ATRP must always be bigger than ADRP.
Can someone confirm or explain to me if I’m wrong.
In case that’s ok, I would greatly appreciate if someone can give me the correct formula for ADRP.
Thank you,
AVERAGETRUERANGE uses a Wilder moving average where as your ADRP uses a simple moving average.
Well, thank you very much good sir, that explains the slight discrepancy. Then it’s not that important. I added both indicators in a single box and go by the highest.