{ Downloaded From https://www.WiseStockTrader.com }
x:=Input("number of periods for APE ratio",2,200,25);
ax:= Max( Abs(HHV(H, x) - Ref(O, -(x-1))), Abs(LLV(L, x) - Ref(O, -(x-1))) );
a1:= Max( Abs(H - O), Abs(L - O) );
ax / a1