It helps to think in terms of arrays of values vs. discrete variables.
Thinkscript def variables are evaluated for each bar on the chart -- just like price, volume, study values, etc. -- and you can access past and future values using [] offset terminology.
So... Your counter variable is...