Download MetaTrader 5

Only one trade per MA Crossover

To add comments, please log in or register

Hi Guys!

 Since I'm very bad at programming, I decided to sign up here and ask you for help.

What line do I have to add in an expert advisor (or what possibility do I have) to achieve, that it opens only ONE trade per crossover. It should not open a new trade as soon as the old one closes.

Thanks in advance for your help.





     int result=0;

     if((iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0)>iMA(NULL,0,200,0,MODE_LWMA,PRICE_CLOSE,0))) // Here is your open buy rule


        result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator",MagicNumber,0,Blue);





         if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;

         if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;







As an example for a buy rule. Now I want it executed only once. Not everytime the previous trade closes.

Thanks :) 

Keith Watford
Keith Watford  

Ea generators produce low quality code.

There is little point in giving advice on coding to someone who doesn't have basic knowledge of coding in mq4

If you write the code yourself, somebody will probably help you 

  1. We hate EA builder
  2. You couldn't be bothered to learn mql4, therefor there is no common language for us to communicate.
  3. There are only two choices: learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds lines of code.
  4. EA builder makes bad code counting up while closing multiple orders.
  5. EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time
  6. EA builder makes bad code Not adjusting for 4/5 digit brokers
  7. EA builder makes bad code not adjusting for ECN brokers.
  8. EA builder makes bad code not checking return codes.
  9. EATree uses objects on chart to save values - not persistent storage (files or GV+Flush.) No recovery (crash/reboot.)

Thanks for your feedback!


Why do you hate EA Builder? It's a simple way to test a strategy, eventhough it has several disadvantages (as you listed) 

Anyway, I wanted to test if the strategy is even worth paying for. At the moment its difficult to learn a programming language due to my lack of free time.

What source would you guys recommend me to learn MQL4? Books? This Forum?


Thanks for every help



To add comments, please log in or register