Can You Help Me With This Simple MA Crossover EA

Hello Everybody,

I am new here, I decided I would like to create an Expert Advisor. I am busy getting familiar with MQL5 and it is going great! I thought I would start of by creating a simple MA crossover EA, and so far so good.

BUT

The problem comes in when I need to open a trade.

I want my EA to only BUY if the candle stick after the MA cross closes higher than the candle stick at the cross. and do the complete opposite for a SELL

I tried using priceInfo[-1].close but that obviously that doesn’t work. (“priceInfo” is the array for mqlRates)

So could this be solved with logic ? Or is there a method that I can use ? And if so any help would be appreciated.

Just a visual explanation:

In other words this is what I would like for a Buy:

And for a Sell:

get the close of the previous candle: double close = iClose(NULL, timeFrame, 1); Then, if (Bid > close) if you want to check if it is higher, and vice-versa if it is lower. Something like that.