I would like to find a way on how to track the number of times that the below strategy has taken maxProfit. The idea is to stop the strategy to run once, we hit certain number of maxProfit.
strategy.exit(id="XL STP", profit = maxProfit, loss = nRes*100)
I do not know a way to track this number while the strategy is being executed.
I did Dave method above but still not working as expected.
The idea is to increment maxProfitReached by 1 every time we have hit our maxProfit. However, when I backtested it, it still doesn't increment the maxProfitReached number although conditions are met.