[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help please, with Easy Language for consective counting and starting over after 9



PureBytes Links

Trading Reference Links

Hi,

Sometime ago I wrote some code to count any consecutive input, IE. H, L, C,
or MedianPrice (or anything else for that mater). This code (below) counts 9
consecutive inputs if they occur in an upward direction and puts the number
on the screen above the bar. The default is set to Close IE. Pr=C. So if
there is 2 consecutive days in a row in which the Close is higher, it will
plot 1 above the first day and 2 above the second day. If there are more
consecutive days, it would plot 3, 4, 5 . . .  until it reaches 9, after
which it continues putting on 9's. I have another similar indicator that
produces the same consecutive count in a downward direction. What I need is
for them to start again with the number 1 after they reach 9 instead of what
they do now. (Which is to continue to put 9's on the chart.) Your help is
appreciated.

Brent
BTW, I realize that a more efficient or elegant method to do this count may
exist, but this is what I came up with.




Inputs: Pr(C);

vars   : Counter (0), String1(""), TextLoc(0), Stren(0);

Condition1 = Pr>=Pr[1];
Condition2 = Pr>=Pr[1] and Pr[1]>=Pr[2];
Condition3 = Pr>=Pr[1] and Pr[1]>=Pr[2] and Pr[2]>=Pr[3];
Condition4 = Pr>=Pr[1] and Pr[1]>=Pr[2] and Pr[2]>=Pr[3] and Pr[3]>=Pr[4];
Condition5 = Pr>=Pr[1] and Pr[1]>=Pr[2] and Pr[2]>=Pr[3] and Pr[3]>=Pr[4]
and Pr[4]>=Pr[5];
Condition6 = Pr>=Pr[1] and Pr[1]>=Pr[2] and Pr[2]>=Pr[3] and Pr[3]>=Pr[4]
and Pr[4]>=Pr[5] and Pr[5]>=Pr[6];
Condition7 = Pr>=Pr[1] and Pr[1]>=Pr[2] and Pr[2]>=Pr[3] and Pr[3]>=Pr[4]
and Pr[4]>=Pr[5] and Pr[5]>=Pr[6] and Pr[6]>=Pr[7];
Condition8 = Pr>=Pr[1] and Pr[1]>=Pr[2] and Pr[2]>=Pr[3] and Pr[3]>=Pr[4]
and Pr[4]>=Pr[5] and Pr[5]>=Pr[6] and Pr[6]>=Pr[7] and Pr[7]>=Pr[8];
Condition9 = Pr>=Pr[1] and Pr[1]>=Pr[2] and Pr[2]>=Pr[3] and Pr[3]>=Pr[4]
and Pr[4]>=Pr[5] and Pr[5]>=Pr[6] and Pr[6]>=Pr[7] and Pr[7]>=Pr[8] and
Pr[8]>=Pr[9];

If CurrentBar >= 1 and Condition1 = True then begin

If Condition1 = True then Counter=1;

If Counter = 1 then String1 = "1";

End;


If CurrentBar >= 1 and Condition2 = True then begin

If Condition2 = True then Counter=1;

If Counter = 1 then String1 = "2";

End;

If CurrentBar >= 1 and Condition3 = True then begin

If Condition3 = True then Counter=1;

If Counter = 1 then String1 = "3";

End;

If CurrentBar >= 1 and Condition4 = True then begin

If Condition4 = True then Counter=1;

If Counter = 1 then String1 = "4";

End;

If CurrentBar >= 1 and Condition5 = True then begin

If Condition5 = True then Counter=1;

If Counter = 1 then String1 = "5";

End;

If CurrentBar >= 1 and Condition6 = True then begin

If Condition6 = True then Counter=1;

If Counter = 1 then String1 = "6";

End;

If CurrentBar >= 1 and Condition7 = True then begin

If Condition7 = True then Counter=1;

If Counter = 1 then String1 = "7";

End;

If CurrentBar >= 1 and Condition8 = True then begin

If Condition8 = True then Counter=1;

If Counter = 1 then String1 = "8";

End;


If CurrentBar >= 1 and Condition9 = True then begin

If Condition9 = True then Counter=1;

If Counter = 1 then String1 = "9";

End;


If Condition1 =true then begin


Plot1(C,"");

 Value3=Text_New(Date[stren],Time,High[stren],String1);
 TextLoc=Text_SetStyle(Value3, 2, 1);

 If GetBackGroundColor=Tool_White then Value4=Text_SetColor(Value3,
Tool_Red)
 Else Value4=Text_SetColor(Value3, Tool_White); {changes numbers to red for
white charts.}




End;