Dynamic stimulis presentation in a loop

I would like to generate grids with different numbers of fields. Therefore, I create a rectangle that I would like to call in a forloop defining how many times to call the stimulus and adjusting the position in regard to the stimulus iteration. can anyone help me by explaining where and how I have to fit in such a forloop? Would be greatful for any suggestion.