I'm quite a python newbie and I would kindly need your help. I'm trying to test a trading strategy very similar to what has been discussed here:
however in my case: once a buy or sell signal is triggered (Gregorio's answer is perfect) the trade has a 2% stop loss and 2% take profit treshold compared to the buy or sell price. hence the strategy would give a positive or negative pnl depending on what will be reached first. is there any way to implement it without using a loop? Reason why I would prefer to avoid a loop is because I have 500,000 rows just for one stock and it would take a really long time. Many thanks