[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ehler' sCenter of Gravity - TASC, May, 2002



PureBytes Links

Trading Reference Links

I tried coding John Ehler's Center of Gravity Indicator
as published in TASC,May, 02, page 21.

When you look back with "Ref" it works very well. However, how far
to look back is always an important issue. So, instead of coding with
tons of Refs, I wanted this script to automate lookback thru
N (N=5 in this case). It works, but when I change this N to 10, 15 or
any other number, the indicator doesn't change. Why? There may
be something wrong with the script. Can u help, please.

/*J.F.Ehler's Center of Gravity, TASC, 05/02*/
EnableScript("Vbscript");
top=0; bot=0
<%
N=5
price=AFL("Close")
toptot=0
bottot=0
for i = 1 to N
bottot=bottot+price(i)
toptot=toptot+(price(i) * N)
N=N-1
next
AFL.Var("top")=toptot
AFL.Var("bot")=bottot
%>
ntop=top+Close;
Cg=ntop/bot;
Graph0=Cg;Graph0Style=8;
Graph1=Cg-ref(cg,-1);












.