NEED HELP- exploration afl for days left in N-day bar to complete.

#1
hello all,
i need help in writing exploration afl for remaining days on n-day bar.
what i try is-
Bix= BarIndex();
for( i = 1; i <=20; i++ )
{
TimeFrameSet(i*indaily);
daysleft=(i - BarsSince((Bix) % i==0));
TimeFrameRestore();
count++;
}
but it gave wrong result:(, finally i found out that for every for loop barindex() value remains the same. as i am new and less experienced in afl writing so it may contains more mistakes.
so i request you all to help me in writing this afl, successfully.
Thanks in Advance.