Hey TJ
That debug tip... what a lifesaver.
OK, I thing I was capable of solve the problem, though it took some time to put things in perpective.
See if my thinking is correct.
I need to calculate
upcount and
dncount only if
count > 2 and within it, calculate
misDays and
pctPer.
Code: Select all
variables:
dat1UpCl (true),
dat1DnCl (true),
dat2UpCl (true),
dat2DnCl (true),
upCount (0),
dnCount (0),
stYear (false),
count (0),
pctPer (0),
misDays (0);
if Year(date) <> Year(date)[1] then begin
stYear = true;
count = 0;
upCount = 0;
dnCount = 0;
end;
if stYear then begin
dat1UpCl = close of data1 >= close [1] of data1;
dat2UpCl = close of data2 >= close [1] of data2;
dat1DnCl = close of data1 <= close [1] of data1;
dat2DnCl = close of data2 <= close [1] of data2;
count = count + 1;
end;
if count > 2 then begin
if dat1UpCl and dat2UpCl then
upcount = upcount + 1;
if dat1DnCl and dat2DnCl then
dnCount = dncount + 1;
misDays = count - (upCount + dnCount);
pctPer = (1 - (misDays / count)) * 100;
end;
plot1(pctPer);
Using 2 sample prints of the same symbol, but different years:
D=20061229, C=1418.30, dat1UpCl=FALSE, dat2UpCl=FALSE, dat1DnCl=TRUE, dat2DnCl=TRUE, count=251, upCount=99, dnCount=74, misDays=78, pctPer= 68.92
D=20070103, C=1416.60, dat1UpCl=FALSE, dat2UpCl=TRUE, dat1DnCl=TRUE, dat2DnCl=FALSE, count=1, upCount=0, dnCount=0, misDays=78, pctPer= 68.92
D=20070104, C=1418.34, dat1UpCl=TRUE, dat2UpCl=FALSE, dat1DnCl=FALSE, dat2DnCl=TRUE, count=2, upCount=0, dnCount=0, misDays=78, pctPer= 68.92
D=20070105, C=1409.71, dat1UpCl=FALSE, dat2UpCl=FALSE, dat1DnCl=TRUE, dat2DnCl=TRUE, count=3, upCount=0, dnCount=1, misDays=2, pctPer= 33.33
D=20070108, C=1412.84, dat1UpCl=TRUE, dat2UpCl=FALSE, dat1DnCl=FALSE, dat2DnCl=TRUE, count=4, upCount=0, dnCount=1, misDays=3, pctPer= 25.00
D=20070109, C=1412.11, dat1UpCl=FALSE, dat2UpCl=TRUE, dat1DnCl=TRUE, dat2DnCl=FALSE, count=5, upCount=0, dnCount=1, misDays=4, pctPer= 20.00
D=20070110, C=1414.85, dat1UpCl=TRUE, dat2UpCl=TRUE, dat1DnCl=FALSE, dat2DnCl=FALSE, count=6, upCount=1, dnCount=1, misDays=4, pctPer= 33.33
In here, on the third day we have 1
upcount, giving us a 33% performance (
pctPer)
D=20081230, C= 890.64, dat1UpCl=TRUE, dat2UpCl=TRUE, dat1DnCl=FALSE, dat2DnCl=FALSE, count=252, upCount=98, dnCount=99, misDays=55, pctPer= 78.17
D=20081231, C= 903.25, dat1UpCl=TRUE, dat2UpCl=TRUE, dat1DnCl=FALSE, dat2DnCl=FALSE, count=253, upCount=99, dnCount=99, misDays=55, pctPer= 78.26
D=20090102, C= 931.80, dat1UpCl=TRUE, dat2UpCl=TRUE, dat1DnCl=FALSE, dat2DnCl=FALSE, count=1, upCount=0, dnCount=0, misDays=55, pctPer= 78.26
D=20090105, C= 927.45, dat1UpCl=FALSE, dat2UpCl=TRUE, dat1DnCl=TRUE, dat2DnCl=FALSE, count=2, upCount=0, dnCount=0, misDays=55, pctPer= 78.26
D=20090106, C= 934.70, dat1UpCl=TRUE, dat2UpCl=FALSE, dat1DnCl=FALSE, dat2DnCl=TRUE, count=3, upCount=0, dnCount=0, misDays=3, pctPer= 0.00
D=20090107, C= 906.65, dat1UpCl=FALSE, dat2UpCl=FALSE, dat1DnCl=TRUE, dat2DnCl=TRUE, count=4, upCount=0, dnCount=1, misDays=3, pctPer= 25.00
D=20090108, C= 909.73, dat1UpCl=TRUE, dat2UpCl=TRUE, dat1DnCl=FALSE, dat2DnCl=FALSE, count=5, upCount=1, dnCount=1, misDays=3, pctPer= 40.00
D=20090109, C= 890.35, dat1UpCl=FALSE, dat2UpCl=FALSE, dat1DnCl=TRUE, dat2DnCl=TRUE, count=6, upCount=1, dnCount=2, misDays=3, pctPer= 50.00
In here, on the third day we have 3
misDays, giving us 0%.
It is quite difficult to transport our ideas to a written formula. I'm always thinking if this is the result that I want
For example, seeing that 0%
pctPer made me questioning if the formula is correct. But since
upcount and
dncount only start when count > 2, it's perfectly normal that on the third day, having a 3
misDays, the result is 0%.