Only one trade per MA Crossover

Back to topics list To post a new topic, please log in or register
avatar
2
Boxxo 2015.05.05 21:12
 

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.

 -Boxxo 

 

EDIT:

{

     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 www..........com",MagicNumber,0,Blue);

        if(result>0)

        {

         TheStopLoss=0;

         TheTakeProfit=0;

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

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

         OrderSelect(result,SELECT_BY_TICKET);

         OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);

        }

        return(0); 

 

-----------------------------------------------------------------------------------------

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

Thanks :) 

avatar
Moderator
3418
GumRai 2015.05.05 22:49 #
 

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 

avatar
13006
WHRoeder 2015.05.06 14:05 #
 
  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.)
avatar
2
Boxxo 2015.05.06 20:25 #
 

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

 

-Boxxo 

Back to topics list  

To add comments, please log in or register