I need your help please on this fractal indicator

 

Hi fellow traders, i got this indicator from a forum. But it gives signals 2 candles late after the reversal had taken place. Can any coder help me to re-code it, so that the signal for the reversal will trigger at the close of current candle of reversal and not 2 candles late after the reversal . Thanks for your precious time .

Files:
Reason: