QULLAMAGGIE ADR formula for AB

ADR code for previous 20 days as opposed to ATR.

_SECTION_BEGIN("MyADR");
Var1 = ((H+L)/2)-1 + ((H+L)/2)-2 + ((H+L)/2)-3 + ((H+L)/2)-4 + ((H+L)/2)-5 + ((H+L)/2)-6 
+ ((H+L)/2)-7 + ((H+L)/2)-8 + ((H+L)/2)-9 + ((H+L)/2)-10 + ((H+L)/2)-11 + ((H+L)/2)-12 
+ ((H+L)/2)-13 + ((H+L)/2)-14 + ((H+L)/2)-15 + ((H+L)/2)-16 + ((H+L)-17)/2 + ((H+L)/2)-18 + ((H+L)/2)-19 + ((H+L)/2)-20;
MyADR = 100*(Var1/20);
Plot(MyADR,"MyADR",colorBlue, styleNoDraw);
_SECTION_END();

Looking to display the ADR % of the previous 20 days, however the result is incorrect.
Any suggestions, thanks.

Hello

May be due to '((H+L)-17)/2' instead of ((H+L)/2)-17 ?

1 Like

@DazN, I briefly looked at the author's site.
On the FAQ page he posted a TC2000 formula. AFAIU, it should be:

// TC 2000 - code - From: https://qullamaggie.com/faq/
// It’s the average daily range in % over the past 20 sessions.
// 100*((H0/L0+H1/L1+H2/L2+H3/L3+H4/L4+H5/L5+H6/L6+H7/L7+H8/L8+H9/L9+H10/L10+
// H11/L11+H12/L12+H13/L13+H14/L14+H15/L15+H16/L16+H17/L17+H18/L18+H19/L19)/20 -1)

period = 20;
ADR = 100 * ( MA( High / Low, period ) - 1 );
Plot( ADR, StrFormat("ADR(%g)", period), colorOrange );

7 Likes

Brilliant, thank you.

1 Like

I was also looking for this ADR formula and I wanted it to display on the top of the chart as text for the current value, so I adapted the code by beppe. Maybe someone else wants to use it too.

_SECTION_BEGIN("ADR");
// adapted to AFL by beppe, https://forum.amibroker.com/t/qullamaggie-adr-formula-for-ab/35933/3
// modified by RioL for userdefined parameters, to be able to use the style "hidden" => current ADR will only be shown in the top of the chart
//////////////////////////////////////////////////////////
// TC 2000 - code - From: https://qullamaggie.com/faq/
// It’s the average daily range in % over the past 20 sessions.
// 100*((H0/L0+H1/L1+H2/L2+H3/L3+H4/L4+H5/L5+H6/L6+H7/L7+H8/L8+H9/L9+H10/L10+
// H11/L11+H12/L12+H13/L13+H14/L14+H15/L15+H16/L16+H17/L17+H18/L18+H19/L19)/20 -1)
Periods = Param("Periods", 20, 2, 300, 1, 10 );
ADR = 100 * ( MA( High / Low, Periods ) - 1 );
Plot( ADR, StrFormat("ADR(%g)", Periods), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

image

If you want to take into account overnight moves you can try:

100*ATR(Period)/MA(C,Period)

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.