PureBytes Links
Trading Reference Links
|
I wrote the following code to create a composite with the cumulative
advance / decline of the NYSE but the results are double what they
should be. I reproduced the results of the first 7 scan iterations
to show what results I got opposed to what I should have gotten.
What am I doing wrong?
Thanks for the help,
Barry Scarborough
Analysis Code
// ~CumAD ticker
// Product a cumulative Advance / Decline ticker where the close is
the Cum AD
// By Barry Scarborough
Adv = Foreign("U.PN","Close"); // stocks that closed up
Dec = Foreign("D.PN","Close"); // stocks that closed down
AddToComposite(Adv,"~CumAd","High",1+2); // add num stocks up
to composite High
AddToComposite(Dec,"~CumAd","Low",1+2); // add num stocks down to
composite Low
AdvDec = Adv - Dec; // get delta of up vs down
AddToComposite(AdvDec,"~CumAd","Volume",1+2); // add delta to volume
xxx = BarIndex(); // determine which bar we are working on
AddToComposite(xxx,"~CumAd","I",1+2); // add bar number to OI for
test purposes
// if first bar set previous value to 0, else get previous
cumulative value
IIf (xxx == 0, PrevCumAd = 0, PrevCumAd = Foreign("~CumAd","Close-
1"));
AddToComposite(PrevCumAd ,"~CumAd","Open",1+2); // add previous
day's value to Open
CumAd = PrevCumAd + AdvDec; // sum today's value with yesterday's
AddToComposite(CumAD,"~CumAd","Close",1+2); // add total to Close
Buy = 0; // required by scan
mode
This is the results of the scan:
Ticker Date Close Open High Low Volume OI
~CumAD 9/30/1999 2214 738 3842 2366 1476 12
~CumAD 9/29/1999 435 145 3220 2930 290 10
~CumAD 9/28/1999 -2307 -769 2260 3798 -1538 8
~CumAD 9/27/1999 1530 510 3550 2530 1020 6
~CumAD 9/24/1999 -1956 -652 2352 3656 -1304 4
~CumAD 9/23/1999 -3849 -1283 1804 4370 -2566 2
~CumAD 9/22/1999 -1389 -463 2496 3422 -926 0
The results of the scan should be:
Ticker Date Close Open High Low Volume OI
~CumAD 9/30/1999 -1774 -2512 1921 1183 738 6
~CumAD 9/29/1999 -2512 -2657 1610 1465 145 5
~CumAD 9/28/1999 -2657 -1888 1130 1899 -769 4
~CumAD 9/27/1999 -1888 -2398 1775 1265 510 3
~CumAD 9/24/1999 -2398 -1746 1176 1828 -652 2
~CumAD 9/23/1999 -1746 -463 902 2185 -1283 1
~CumAD 9/22/1999 -463 0 1248 1711 -463 0
When the scan is run the values that end up in High, Low, Volume
and OI are double what they should be.
The open value for 9/22 should be 0 because the iff statement should
have set it to zero but it has a the first delta value. What is
wrong with the IFF statement?
And of course, from there the math gets all screwed up.
What is wrong with the coding that causes it to product invalid
results?
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|