Depends on the volume, Your code would work if marketVol is the volume of the last quote. If it is something different or no volume at all, modify the code or generate other types of bars.