If you see the zero line this means the solutions give the same results.
The best results was achieved on the odd lengths.
1) Do not try to reinvent the wheel.
2) Always check the Pine Script docs to find already implemented solutions.
A list of Paid indicators:
Toss a coin to your witcher: