Has anyone successfully programmed martingale position sizing in Tradestation? I am have trouble getting my code to work. if positionprofit(1)>=0 then size=1; if positionprofit(1)<= then size=size+1; The problem with this is that it calculates every bar, so "size=size+1" keeps counting after every bar. I have tried various tweaks but could not get it to work. It is especially problematic when a trade reverses a previous trade without any time in between.