Brooke,
You got me thinking about how well I had tested the VIDYA scan I wrote last September. No, it did not produce results that agreed with the spreadsheets that are around. However, the scan below does.
The previous version is still valid, just not the same as the spreadsheets.
My original scan implemented the VIDYA trading system back in Chapter 8 A CMO Driver Trading System (equ 8.1) wherease the spreadsheets use versions of the equations found up in Chapter 3 where the concepts are introduced (eqs 3.7 and 3.8a). There are still more versions of the equations -- Volitility Index Driven (equs 3.1 and 3.2) and StdDev driven (equ 3.5).... sometime when I have more time I'll dig into these others and determine which makes the most sense to use (the Volitility based one at equs 3.1 and 3.2 sure look interesting).
This scan tracks with the spreadsheets exactly, although I have issues with those spreadsheets, namely their use of the 9 DMA regardless of the trade hold time. This seems contraty to what Richard has taught us (and I beleieve he has said it at least three times now because I seem to remember it).
I like to set the start variable in this scan to more days then necessary so that the VIDYA MA can nudge away from the initial value, I initalize it to the close of the start day as a starting point, also different from the spreedsheets.
Take this scan out for a test drive and let me know how it feels.
// // Scan Title : Variable Moving Average // (TS Chande's VIDYA) // ** per eqs 3.7 and 3.8a // // Written By : Jeffrey L. Grover // noman@gatech.edu // // Create Date: 2 Jan 1998 // // ********+-----------------------------------+******* // ********| NO WARRENTY EXPRESSED OR IMPLIED |******* // ********+-----------------------------------+******* //
//input ="one.lst"; input = "ibd_7070.lst"; output = "vidya.lst"; issuetype=common; exchange nyse,nasdaq,amex;
float upper, lower, width, updays, dndays; float t, vidya, vidyay, vidyab, cmo, a; integer d, trdpd, start, i,j;
trdpd := 9; t := 2.0/(trdpd+1); start := -20; width := .1;
vidya := close(start); vidyay := 0.0;
for d = start to 0 step 1 do
updays := 0; dndays := 0;
// develop MAs of up and Down days
for j = 0 to 8 step 1 do
i := d - j; if close(i) > close(i-1) then updays := updays + (close(i) - close(i-1)); endif;
if close(i) < close(i-1) then dndays := dndays + (close(i-1) - close(i)); endif;
next j;
if (updays+dndays) = 0 then updays := 0.0001; endif;
vidyab:= vidyay; vidyay:= vidya;
cmo := abs((updays - dndays)/(updays + dndays)); vidya := (t * cmo * close(d)) + ((1 - (t * cmo)) * vidyay);
// Then calc upper and lower bands
upper := vidya * (1 - width); lower := vidya * (1 + width);
// println d," , ", close(d)," , ",updays," , ",dndays," , ",cmo," , ",vidya," , "," , ",lower," , ";
next d;
if close(0) >= vidya and close(-1) >= vidyay and close(-2) < vidyab then println Symbol:-6,"BUY , Cl: ":-5,Close(0):7:3," VIDYA: ":-5,vidya:7:3; endif;
if close(0) <= vidya and close(-1) <= vidyay and close(-2) > vidyab then println Symbol:-6,"SELL, Cl: ":-5,Close(0):7:3," VIDYA: ":-5,vidya:7:3; endif; |