Hi,
I am trying to write an exploration to loop back thru 3 arrays to
confirm how many days ago there was a crossover of the 3 moving
averages defined below. This is related the the Bill Williams Chaos
Theory ( the alligator). Once the exploration is executed I would be
able to see which stocks are still in an uptrend and have been in an
uptrend for the longest time.
However in my current formula, the for loop drops out on the very
first pass. I cannot figure out why. It never adds anything to the
NumberOfDays variable.
I am certain the checkAlligator formula is correct as i tested it
manually. I just added the ref() and the index counter for my
formula, so it could loop back through the data.
I would be gratefully if someone could explain to me what i a doing
incorrectly? or point me in the correct direction.
Thank you kindly in advance...
Regards,
Tony
A=((H+L)/2);
AlligatorBlue=Ref(Wilders(A,13),-8);
AlligatorRed=Ref(Wilders(A,8),-5);
AlligatorGreen=Ref(Wilders(A,5),-3);
CheckAlligator = 0;
NumberOfDays =0;
for ( i=-1; stop = 0 ; i--)
{
CheckAlligator =IIf( Ref(AlligatorGreen,i) > Ref(AlligatorRed,i) AND
Ref(AlligatorGreen,i) > Ref(AlligatorBlue, i) AND
Ref(AlligatorRed,i) > Ref(AlligatorBlue, i) ,1, 0);
// if in uptrend increment the NumberOfDays variable
if (CheckAlligator == 1 )
NumberOfDays = 1 + NumberOfDays;
else
stop = 1;
}// end for loop
Filter = C > 1;
AddColumn(i , "index ");
AddColumn(Checkalligator , "Checkalligator");
AddColumn(NumberOfDays , "NumberOfDays ");
AddColumn(Close , "Close");
AddColumn(AlligatorGreen, "AlligatorGreen");
AddColumn(AlligatorRed, "AlligatorRed");
AddColumn(AlligatorBlue, "AlligatorBlue");