Converting TradingView trailing stop

 

Hello everyone, i've developed a pine script which does not use SL/TP but trailing stop. I've decided to make an EA and i was wondering if i could reach quite the same results. do you have any suggestions? I attach the pine script here, if you run it on any market (better if using heikin-ashi) you will see how does it perform. Thank you!

Files:
Script.txt  3 kb
Reason: