how to calculate a percentage,

**over one year**, the number of closes up and down?

I tried many "things" without success.

here is my script

Code: Select all

`Inputs: `

EtudeLength(200);

Variables:

CounterCloseUp(0), CounterCloseDn(0), Counter(0),

PctCloseUp(0), PctCloseDn(0);

Arrays:

ArrayCloseUp[200](0), ArrayCloseDn[200](0);

If BarNumber <> BarNumber[1] then

begin

If Close >= Close[1] then

CounterCloseUp = 1

else

CounterCloseUp = 0;

If Close < Close[1] then

CounterCloseDn = 1

else

CounterCloseDn = 0;

end;

For Value1 = 0 to (EtudeLength-1)

begin

If Close >= Close[1] then

begin

ArrayCloseUp[EtudeLength - Value1] = ArrayCloseUp[(EtudeLength-1)-Value1];

ArrayCloseUp[0] = CounterCloseUp;

end;

If Close < Close[1] then

begin

ArrayCloseDn[EtudeLength - Value1] = ArrayCloseDn[(EtudeLength-1)-Value1];

ArrayCloseDn[0] = CounterCloseDn;

end;

end;

If BarNumber <> BarNumber[0] and BarNumber >= EtudeLength then

begin

PctCloseUp = AverageArray(ArrayCloseUp, EtudeLength);

PctCloseDn = AverageArray(ArrayCloseDn, EtudeLength);

end;

Print("DATE: ", formatdate("dd-MM-yyyy ", eldatetodatetime(date)),

newline, " ArrayCloseDn[0] ",ArrayCloseDn[0], " ArrayCloseDn[1] ",ArrayCloseDn[1], " ArrayCloseDn[2] ",ArrayCloseDn[2],

newline, " ArrayCloseUp[0] ",ArrayCloseUp[0], " ArrayCloseUp[1] ",ArrayCloseUp[1], " ArrayCloseUp[2] ",ArrayCloseUp[2]);

Plot1(PctCloseUp, "PctCloseUp");

SetPlotColor(1, DarkGreen);

SetPlotWidth(1, 2);

Plot2(PctCloseDn, "PctCloseDn");

SetPlotColor(2, DarkRed);

SetPlotWidth(2, 2);

Nuno