Help with my EA.

I just ended up a MQL4 course and started to mess around with Meta Editor, just a simple MA crossover EA, but I'm having a few problems:

1- I want the EA to open a trade on the next crossover, not on the current one.

2- I can't get the EA to close the first order and then open another one.

The course was damn basic, I think the issue is related to the void Something() stuff, because it was not seen on the code we made, we only use OnTick function, and the system was oriented to work only on a certain hour, so I think I'm trying to code a different kind of system using the wrong logic.

FernandoBorea: Sorry, I'm not too good at english, for example, let's say signal MA is over Slow and Fast one, when I attach the EA it immediately opens the trade even though the crossover was some bars ago.

Because you don't check crossover but just the position of SignalMA. If you want to check crossover you should compare the previous position with the current position.

Why do you use this? The variable "Pips" isn't use in your code! You can delete the whole block.

Similar problem. Result of this block is TradeLots is equal to Lots. You should use just Lots. You can delete the whole block.

You shouldn't use this coding

You should use this instead of

Pips variable it's for 4 to 5 broker digits conversion.

Lots was a mistake I just noticed, I posted an old version, that block was just to test on some logical conditions when I was on the course. I was going to use the structure to set SLLevel and TPLevel because if I set it to 0 on the variable then because of the Bid +/- SL/TP*Pips would place the SL at entry

Could you please explain me the difference between using (!res) and then else? What does " ! " Do?

OrderClosePrice() returns close price. If you close the order for example at 1.23000 the OrderClosePrice() will return 1.23000. If the order is still open the OrderClosePrice() returns 0.0 . Similar to OrderCloseTime()