Lipton, with all due respect, now I think that you are not doing it wrong, and that you are not doing it to cheat, but I have to tell you that this EA will only work if you can create libraries so that it changes the historical file every 4 hours and another library so that it checks that winapi is working fine. I think this is the solution for this code, I have created bat files for the windows task to restart the terminal every 4 hours, but this did not work either. If you keep working on this think about creating the libraries and include them to the expert, for example: #include <chekhistory.mqh>. kernel32 reads the hst but if you don't delete the file and re-download you have a problem.
Likewise, if you ensure that this EA updates the history, I will schedule the tasks with a bat file to delete all the hst files every 4 hours and another task that restarts the EA, then I'll tell you if this works.
You have spent time on this and I got confused when criticizing you, I have also worked on this EA, if you change the history to 30 min the results are better, the problem is in the update on each candle, there accounts are broken.