SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Strategies & Market Trends : TA-Quotes Plus -- Ignore unavailable to you. Want to Upgrade?


To: Jan Robert Wolansky who wrote (9058)3/18/1999 9:33:00 PM
From: John Schott  Read Replies (2) | Respond to of 11149
 
LN/SQRT Scan - using QP Financial Studio

It ain't quite a scan, but can we use QPFS?

The second Beta (last week) has got all the needed math functions (LN, SQRT and much more). It looks easy this way.

And Gary mentioned that there was another Beta coming.......

Doing that stuff in QP2 ain't no cup of tea. Every try to figure out how to do a square root doing only the mathematical operators in QP2. You did, then you remember college math better than I did. OK, now try a natural log? I think the word is sort of close to "impossible" (I'm not even sure a long long series expansion will do it?).



To: Jan Robert Wolansky who wrote (9058)3/20/1999 6:14:00 PM
From: TechTrader42  Respond to of 11149
 
Jan: This is a QP2 scan translation of a Metastock version of the AIQ
Volatility Indicator. I owe a lot to Jeff Grover and Bob Jagow for
their earlier work on square roots and logs. I've left a lot of junk
in the output to show how the value of the volatility index is
gradually built. Maybe you can let us know how you use the indicator.
Thanks.

//AIQ Volatility Indicator, translated for QP2 by Brooke
//input="volvol.lst";
output="volatility.lst";
float x,xx,n,n3,n5,n7,n9,n11,n13,n15,lnx,sumlnx,sumlnxlnx,
sumlnxsumlnx,formula1,formula2,in,out,fx,xxx;
integer i,j;
sumlnx:=0;
sumlnxlnx:=0;
for i=-20 to 0 step 1 do
x:=close(i)/close(i-1);

if x >= 100000 then xx := x /100000; else
if x >= 10000 then xx := x / 10000; else
if x >= 1000 then xx := x / 1000; else
if x >= 100 then xx := x / 100; else
if x >= 10 then xx := x / 10; else
xx := x; endif; endif; endif; endif; endif;

n :=(xx-1)/(xx+1); n3 :=n*n*n; n5 :=n3*n*n;
n7 :=n5*n*n; n9 :=n7*n*n; n11 :=n9*n*n;
n13 :=n11*n*n; n15 :=n13*n*n;

lnx := 2*(n+n3/3+n5/5+n7/7+n9/9+n11/11+n13/13+n15/15); //Log(C/Ref(C,-1))

if x >= 100000 then lnx := lnx + 11.51293; else
if x >= 10000 then lnx := lnx + 9.21034; else
if x >= 1000 then lnx := lnx + 6.90776; else
if x >= 100 then lnx := lnx + 4.60517; else
if x >= 10 then lnx := lnx + 2.30258;
endif; endif; endif; endif; endif;

sumlnx:= sumlnx+lnx; //Sum(Log(C/Ref(C,-1)),21)
sumlnxlnx:=sumlnxlnx+(lnx*lnx); //Sum((Log(C/Ref(C,-1))*Log(C/Ref(C,-1))),21)
next i;
sumlnxsumlnx:=sumlnx*sumlnx; //((Sum(Log(C/Ref(C,-1)),21)*Sum(Log(C/Ref(C,-1)),21))
formula1:=sumlnxlnx-(sumlnxsumlnx/21); //( Sum((Log(C/Ref(C,-1))*Log(C/Ref(C,-1))),21) -
// ((Sum(Log(C/Ref(C,-1)),21)*Sum(Log(C/Ref(C,-1)),21)) )/21)
formula2:=12.5*formula1;
println symbol:-5, " ", "sumlnx: ", " ", sumlnx:10:5, " ",
"sumlnxlnx: ", " ", sumlnxlnx:10:5, " ",
"sumlnxsumlnx: ", " ", sumlnxsumlnx:10:5, " ",
"formula1: ", " ", formula1:10:5, " ",
"formula2: ", " ", formula2:10:5, " ",
symbol:-5;

in := formula2;
xxx := 1.0;
fx := 1.0;
for j = 0 to 9 step 1 do
xxx := xxx - fx/(2*xxx);
fx := xxx*xxx - in;
next j;
out := xxx;
println symbol, ", ", "AIQ Volatility Indicator: ", " ", 100*out:6:2;




To: Jan Robert Wolansky who wrote (9058)3/20/1999 7:00:00 PM
From: TechTrader42  Read Replies (1) | Respond to of 11149
 
Jan: I notice that in your formula, the period is the variable n:

V=100* the square root of ( (250/n-1)*(the sum of the square of the
log of the change in price from the prior period minus the square of
the sum of the log of change in price from the prior period divided by
n).


Here's the whole QP2 translation again with variable periods. Your "n"
is "period" in the scan. I've set it to 14 this time. Values exactly
match those in Metastock.


//AIQ Volatility Indicator, translated for QP2 by Brooke
input="volvol.lst";
output="volatility.lst";
daystoload=500;
float x,xx,n,n3,n5,n7,n9,n11,n13,n15,lnx,sumlnx,sumlnxlnx,
sumlnxsumlnx,formula1,formula2,in,out,fx,xxx,period;
integer i,j;
period:=14;
sumlnx:=0;
sumlnxlnx:=0;
for i=-(period-1) to 0 step 1 do
x:=close(i)/close(i-1);

if x >= 100000 then xx := x /100000; else
if x >= 10000 then xx := x / 10000; else
if x >= 1000 then xx := x / 1000; else
if x >= 100 then xx := x / 100; else
if x >= 10 then xx := x / 10; else
xx := x; endif; endif; endif; endif; endif;

n :=(xx-1)/(xx+1); n3 :=n*n*n; n5 :=n3*n*n;
n7 :=n5*n*n; n9 :=n7*n*n; n11 :=n9*n*n;
n13 :=n11*n*n; n15 :=n13*n*n;

lnx := 2*(n+n3/3+n5/5+n7/7+n9/9+n11/11+n13/13+n15/15); //Log(C/Ref(C,-1))

if x >= 100000 then lnx := lnx + 11.51293; else
if x >= 10000 then lnx := lnx + 9.21034; else
if x >= 1000 then lnx := lnx + 6.90776; else
if x >= 100 then lnx := lnx + 4.60517; else
if x >= 10 then lnx := lnx + 2.30258;
endif; endif; endif; endif; endif;

sumlnx:= sumlnx+lnx; //Sum(Log(C/Ref(C,-1)),21)
sumlnxlnx:=sumlnxlnx+(lnx*lnx); //Sum((Log(C/Ref(C,-1))*Log(C/Ref(C,-1))),21)
next i;
sumlnxsumlnx:=sumlnx*sumlnx; //((Sum(Log(C/Ref(C,-1)),21)*Sum(Log(C/Ref(C,-1)),21))
formula1:=sumlnxlnx-(sumlnxsumlnx/period); //( Sum((Log(C/Ref(C,-1))*Log(C/Ref(C,-1))),21) -
// ((Sum(Log(C/Ref(C,-1)),21)*Sum(Log(C/Ref(C,-1)),21)) )/21)
formula2:=12.5*formula1;
println symbol:-5, " ", "sumlnx: ", " ", sumlnx:10:5, " ",
"sumlnxlnx: ", " ", sumlnxlnx:10:5, " ",
"sumlnxsumlnx: ", " ", sumlnxsumlnx:10:5, " ",
"formula1: ", " ", formula1:10:5, " ",
"formula2: ", " ", formula2:10:5, " ",
symbol:-5;

in := formula2;
xxx := 1.0;
fx := 1.0;
for j = 0 to 9 step 1 do
xxx := xxx - fx/(2*xxx);
fx := xxx*xxx - in;
next j;
out := xxx;
println symbol, ", ", "AIQ Volatility Indicator: ", " ", 100*out:6:2;



To: Jan Robert Wolansky who wrote (9058)3/21/1999 11:37:00 AM
From: TechTrader42  Read Replies (3) | Respond to of 11149
 
Jan: Here's a version of the AIQ volatility scan that gives past
values. What larks, eh?

//AIQ Volatility Indicator,
//translated by Brooke
//from Jan Robert Wolensky's Metastock version
//with Square Root and Log formulas by Jeff Grover, Bob Jagow
//100*(Sqrt(12.5*
//(Sum((Log(C/Ref(C,-1))*Log(C/Ref(C,-1))),21)-
//((Sum(Log(C/Ref(C,-1)),21)*Sum(Log(C/Ref(C,-1)),21)))/21)))
//100*(Sqrt(12.5*
//(Sum((Log(C/Ref(C,-1))*Log(C/Ref(C,-1))),21)-
//((Sum(Log(C/Ref(C,-1)),21)*Sum(Log(C/Ref(C,-1)),21)))/21)))
//AIQ Volatility Indicator, translated for QP2 by Brooke
input="volvol.lst";
output="volatility.lst";
daystoload=500;
float x,xx,n,n3,n5,n7,n9,n11,n13,n15,lnx,sumlnx,sumlnxlnx,
sumlnxsumlnx,formula1,in,out,fx,xxx,period,formula2;
integer i,j,k;
period:=21;

for k= 0 to 10 do
sumlnx:=0;
sumlnxlnx:=0;

for i=-(period-1) to 0 step 1 do
//Jeff Grover's log formula
//for k= 0 to 1 do
x:=close(i-k)/close((i-1)-k);
if x >= 100000 then xx := x /100000; else
if x >= 10000 then xx := x / 10000; else
if x >= 1000 then xx := x / 1000; else
if x >= 100 then xx := x / 100; else
if x >= 10 then xx := x / 10; else
xx := x; endif; endif; endif; endif; endif;
n :=(xx-1)/(xx+1); n3 :=n*n*n; n5 :=n3*n*n;
n7 :=n5*n*n; n9 :=n7*n*n; n11 :=n9*n*n;
n13 :=n11*n*n; n15 :=n13*n*n;
lnx := 2*(n+n3/3+n5/5+n7/7+n9/9+n11/11+n13/13+n15/15);
if x >= 100000 then lnx := lnx + 11.51293; else
if x >= 10000 then lnx := lnx + 9.21034; else
if x >= 1000 then lnx := lnx + 6.90776; else
if x >= 100 then lnx := lnx + 4.60517; else
if x >= 10 then lnx := lnx + 2.30258;
endif; endif; endif; endif; endif;
//next k;
sumlnx:= sumlnx+lnx;
sumlnxlnx:=sumlnxlnx+(lnx*lnx);
next i;
sumlnxsumlnx:=sumlnx*sumlnx;
formula1:=12.5*(sumlnxlnx-(sumlnxsumlnx/period));
//Square root formula by Jeff Grover, Bob Jagow
in := formula1;
xxx := 1.0;
fx := 1.0;
for j = 0 to 9 step 1 do
xxx := xxx - fx/(2*xxx);
fx := xxx*xxx - in;
next j;
out := xxx;
println symbol:-5, " ", date(-k), " ", "AIQ Volatility Indicator: ", " ", 100*out:6:2;
next k;