Macro, loops and variables

I guess this is what you want

import Term.progress: track, ProgressBar, update, start, stop
macro track(ex)
    iter = esc(ex.args[1].args[2])
    i = esc(ex.args[1].args[1])
    body = esc(ex.args[2])
    quote
        N = length($iter)
        let pbar = ProgressBar(;N=N)
            try 
                for $i in $iter
                    $body
                    update(pbar)
                end
            finally
                stop(pbar)
            end
        end
        nothing
    end
end