Buy or Sell only once signal is occurred

Anton Gruber  

Hi,

I m new to mql5 and also for programming. I have a little problem I can't solve alone.

I have written a little EA for buying or selling if a signal is occurred.

For example: I wan't to buy once the price is obove EMA 20 and than the next trade should only be opened at the opposite direction when the price is below the EMA 20 and so on.

Short: by if the price is above EMA20 than stop until the price falls below the EMA20 and sell, and so on.

Is this only doable with a while or for loop or is there a simple function or an other way to solve this? I don't have find a sulotion in the manual.

Thanks for any help.

edit

One thing more to say, the trade should run until the stop loss or take profit is hitten.
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
Reason: