In the beginning alerts came directly after the divergence formed but now I noticed that alerts get sent 2 candles after the divergence formed. If anyone else has the same problem or has a solution, please let me know.
@crazyheinz, This script uses 5 bar fractals so the signals have a 2 bar lag. With a 3 bar fractal you would have 1 bar lag. It is a lag indicator. If applied to a leading indicator lika a momentum the lead of the momentum compensates the lag. The leading indicators may fail. No one can predict the future 100% especially when you are dealing with human emotions.
@sal157011, thx for your reply. Mistyped yesterday, it sent an alert after 1 candle after the divergence. Of course every indicator can fail but for my trading strategy divergences work extremely well. If I could fix the delay of the notification I would be really happy :)