Help with code greatly appreciated.

 

Hello all,

As you have all heard probably a million times; I am not a coder. I put together this simple MA crossover strategy using an EA builder and having to tweak it to get it working by reading code samples in forums.

My strategy was running in a M1 chart for June 8th with a very negative equity curve. I wanted to test in the M1 because of all the chop. My EA would enter a trade and when it exited automatically entered a trade the other direction. As you can imagine it generated a lot of trades in 24 hours of ticks.

I searched and looked at numerous pieces of code to see how I could prevent the reverse trade on exit. I found a methodology I liked that checked to see if it was a period of time since the last candle traded. I changed it to work for the M1. However now my strategy fires off multiple trades on a candle.

I have attached the code; any help would be appreciated

Coins

Files:
MMA-v1.23.mq4  8 kb
Reason: