weird 100% spikes
Posted: 11 Oct 2009
Hi
I elaborated a bit more my previous formula and I though that it would be better to open a new thread about it since this is a separate issue.
Why at the first day of each year the indicator spikes til 100% or 0%?
I can't see where the problem might be
I elaborated a bit more my previous formula and I though that it would be better to open a new thread about it since this is a separate issue.
Why at the first day of each year the indicator spikes til 100% or 0%?
I can't see where the problem might be
Code: Select all
// this indicator shows the percentage of days in which data2 closes in accordance with data1
// the objective is to shows us a simple way to measure performance (in time) of a stock or sector against, for example, an index
variables:
dat1UpCl (true),
dat1DnCl (true),
dat2UpCl (true),
dat2DnCl (true),
upCount (0),
dnCount (0),
stYear (false),
count (0),
pctPer (0),
misDays (0);
if bartype = 2 then begin
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;
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;
end
else begin
alert(text("This indicator is only applied to daily charts"));
end;
plot1(pctPer);