Adding and Closing Multiple Positions Dependant on Criteria

Apologies if this is covered elsewhere or a super obvious question.

I want to increase and decrease position sizes i.e. phase in an out of the stock.

buy = cross (close, MA) // buy when price crosses over MA
buy = cross (close, MA2) // buy more (add to position) when price crosses over second MA
close = cross (MA2, close) // close one of my two positions
close = cross (MA, close) // close second position

Many thanks.


I agree it should be included in Seetu.

I need to find a way how to implement the “scale-in” / “scale-out” mechanism.

Look forward to it. In the mean time I guess I can run as separate programs, not ideal but an interim fix. Thanks.