Need help fixing this small EA

 

I need help getting my first Expert Advisor to work in Strategy Tester. The attached debugEA.mq4 is a short, simplified version which fails in the same manner. This version waits for a new hourly candle and the SMA8 crossing SMA24 to open and close trades. The problem is that when I run it in Strategy Tester, it opens the first trade at the appropriate time, but it does not close the trade nor open any new trades at subsequent MA crossovers. What am I doing wrong? I will be grateful to anyone who can find the problem and correct it.

Files:
debugea.mq4  2 kb
 

Hi,

I've made some changes.

It works now.

SteveBrown:
I need help getting my first Expert Advisor to work in Strategy Tester. The attached debugEA.mq4 is a short, simplified version which fails in the same manner. This version waits for a new hourly candle and the SMA8 crossing SMA24 to open and close trades. The problem is that when I run it in Strategy Tester, it opens the first trade at the appropriate time, but it does not close the trade nor open any new trades at subsequent MA crossovers. What am I doing wrong? I will be grateful to anyone who can find the problem and correct it.
Files:
 

Thanks, igorad. God bless you.

 

Incorporating igorad's changes, I revised the EA in order to implement the basic MA crossover strategy accurately. Although it is a losing trading strategy, this EA may serve as a good "bare bones" template on which to build Expert Advisors.

Files:
 

This EA also works fine with 5M timeframes as well

Probably also would work with any other timeframes, too.

Reason: