I want to limit the amount of trades my script can be in at any one time. I can get in and out of positions, but I want to limit total to 5 so I dont have too much risk or draw down. I use below to get in/out of trade.
strategy.entry(id = "Long", long = true, when = minLongMoveTrue, stop = percentMove)
strategy.entry(id = "Short", long = true, when = minShortMoveTrue, stop = percentMove)
strategy.position_size
seems only look at total shares active, but cannot discern how many active trades I am in.
Maybe I need to set up a counter since pine script doesnt have inbuilt function?