I'm trying to solve some calculations for prior swing highs/lows when my script loads up. When it initially loads up I need to perform the calculation for the previous 5 highs/lows. But on an ongoing basis I need to only maintain the current pivot. Is there a way to achieve that efficiently as right now I think I'm running this loop every time 5 times.
thanks in advance for your help
Comment