Change EA to open bar?

 

I have an EA I coded up that is showing profit when optimized on Open bar.  If I change the Ea to work with open bar will I get the same results?

What code do I need to implement?   Will Trail profit and Trail stop function work correctly with open bar ?

FYI MT5 Code