First, please verify your license as described here: License Verified badge
Second, you should learn to take advantages of AmiBroker's powerful array-processing operations rather than doing everything with loops.
Third, your qty_m variable is a scalar not an array. Therefore, when you exit the loop it will have a single value, not a different value for each bar.