EA problem!

 

Hi,


Can anyone help me.
I am having an intermittent problem with my EAs.
My EA's are very simple. They calculate the order size based on the previous high/low and place an buy/sell order and place a stop.

When I start my MT4 platform the EA's will sometimes load automatically! They are not coded to do that. They are very specifically drag and drop EAs.

I generally have 5 charts open. 4 of 1 pair (different timeframes).
The other chart is a different pair.
There is no consistency in how they load.  Some days they won't load at all. Other days they can load on any number of charts.
I have checked the log file. The EAs load within a few seconds of starting the platform along with my other standard indicators and before connecting to the brokers server.

Does any one have an idea what could be causing the issue and how to resolve it?

Thanks

Keef

 
  1. They are not coded to do that
    They don't need to be. You attach a EA to a chart, it runs there, until you remove it.
  2. They are very specifically drag and drop EAs
    No such thing is useful. A script can be dropped.
  3. They calculate the order size based on the previous high/low and place an buy/sell order and place a stop.
    Makes no sense
    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    • Do NOT use TickValue by itself - DeltaPerLot
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out

  4. I have checked the log file. The EAs load within a few seconds of starting the platform along with my other standard indicators and before connecting to the brokers server.
    Exactly what should happen.
  5. Does any one have an idea what could be causing the issue and how to resolve it?
    There is no issue except your misunderstanding what a EA does and how the terminal works.
 

There is not enough details to give you a good answer.


When I start my MT4 platform the EA's will sometimes load automatically! They are not coded to do that. They are very specifically drag and drop EAs.



They are probably loaded when you shut down the platform so they will reload when you restart the platform.

The EA must be coded to do what you require, so you will need to modify your code.

 
whroeder1:
  1. They don't need to be. You attach a EA to a chart, it runs there, until you remove it.


  1. No such thing is useful. A script can be dropped.


  1. Makes no sense
    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    • Do NOT use TickValue by itself - DeltaPerLot
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out

  2. Exactly what should happen.
    There is no issue except your misunderstanding what a EA does and how the terminal works.

1. I'm not using any scripts
    Exactly "I" attach the EA to the chart. It does what it is coded to do then removes itself.
2. No, I'm not misunderstanding what an EA does.
What i don't understand is why the EA is loading at start up without any input from me?

 
Keith Watford:

There is not enough details to give you a good answer.

They are probably loaded when you shut down the platform so they will reload when you restart the platform.

The EA must be coded to do what you require, so you will need to modify your code.

No, the EA's are not loaded when i shut down the platform.
That is why i don't understand how they can load at the start up.

Apart from the self loading issue, the EA's do exactly what they are supposed to do.
 
keefymonster:

Exactly "I" attach the EA to the chart. It does what it is coded to do then removes itself.

What code are you using for the EA to remove itself?

keefymonster:

My EA's are very simple. They calculate the order size based on the previous high/low and place an buy/sell order and place a stop.

That sounds better suited to a script than an EA, and as a script it would avoid any "removal" issues.

 
keefymonster:
No, the EA's are not loaded when i shut down the platform.
That is why i don't understand how they can load at the start up.

Apart from the self loading issue, the EA's do exactly what they are supposed to do.

I don't see how that is possible.

I am not sure about EAs, but it used to be that you could get problems by not shutting down properly. I'm not sure about now because I shut down properly every time. If you shut down the computer without shutting down the platform, when you start the platform again, it can revert to whatever state it was in the last time that it was shut down correctly.

As you have been advised, better to use a script.

 
honest_knave:

What code are you using for the EA to remove itself?

That sounds better suited to a script than an EA, and as a script it would avoid any "removal" issues.

double HIGH;
   double LOW;
   input double percentage=2;
   input string Note="Pepperstone";
   double buffer=0.3;
   input double commission=7;
   input double commsfactor=0.7;
         
#include <WinUser32.mqh>
int Ticket;
double lot;

void OnTick()
 {
   double spread=MarketInfo(Symbol(),MODE_SPREAD);
   double piploss;
   double exposure;
   double HIGHp;
   double LOWp;
   double lot1;
   double exposure1;
   double comms;
   
   HIGH = NormalizeDouble(High[1],5);
   HIGHp = HIGH * 1000;
   LOW = NormalizeDouble(Low [1],5);
   LOWp = LOW * 1000;
   piploss=NormalizeDouble(((((Bid-LOW)*1000+spread)/10)+2*buffer),5);
   exposure1=AccountBalance()*(percentage/100);
   lot1 = NormalizeDouble((exposure1/(piploss*0.001)/10000),2);
   comms=lot1*commission*commsfactor;
   exposure=(AccountBalance()*(percentage/100)-comms);
   lot = NormalizeDouble((exposure/(piploss*0.001)/10000),2);
         
        if (Bid > HIGH+0.001){
        Ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,3,LOW-0.003,0,"Buy order",16385,0,CLR_NONE);
        Print ("High = ", HIGHp);
        Print ("Low = ", LOWp);
        Print ("Open = ", NormalizeDouble (Bid*1000,5));
        Print ("Tradesize = ",piploss);
        Print("Lot size ",lot);
        Print("Lot size1 ",lot1);
        Print ("spread = ",spread);
        Print ("Ticket = ",Ticket);
        Print ("Commission = ",comms);
        
        if (Ticket>0){
       ExpertRemove();      
      }
}  
}

This is the whole code i use. As you can see it is very simple.
I do not have any problem loading the EA manually or with the EA removing itself after it has performed its function.
I absolutely make sure no EAs are active before I shut the system down.
What I can't understand is how the EA can possibly load itself onto any number of open charts when I start MT4.
Thank you for your help with this issue.

Any ideas?

 
keefymonster:
double HIGH;
   double LOW;
   input double percentage=2;
   input string Note="Pepperstone";
   double buffer=0.3;
   input double commission=7;
   input double commsfactor=0.7;
         
#include <WinUser32.mqh>
int Ticket;
double lot;

void OnTick()
 {
   double spread=MarketInfo(Symbol(),MODE_SPREAD);
   double piploss;
   double exposure;
   double HIGHp;
   double LOWp;
   double lot1;
   double exposure1;
   double comms;
   
   HIGH = NormalizeDouble(High[1],5);
   HIGHp = HIGH * 1000;
   LOW = NormalizeDouble(Low [1],5);
   LOWp = LOW * 1000;
   piploss=NormalizeDouble(((((Bid-LOW)*1000+spread)/10)+2*buffer),5);
   exposure1=AccountBalance()*(percentage/100);
   lot1 = NormalizeDouble((exposure1/(piploss*0.001)/10000),2);
   comms=lot1*commission*commsfactor;
   exposure=(AccountBalance()*(percentage/100)-comms);
   lot = NormalizeDouble((exposure/(piploss*0.001)/10000),2);
         
        if (Bid > HIGH+0.001){
        Ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,3,LOW-0.003,0,"Buy order",16385,0,CLR_NONE);
        Print ("High = ", HIGHp);
        Print ("Low = ", LOWp);
        Print ("Open = ", NormalizeDouble (Bid*1000,5));
        Print ("Tradesize = ",piploss);
        Print("Lot size ",lot);
        Print("Lot size1 ",lot1);
        Print ("spread = ",spread);
        Print ("Ticket = ",Ticket);
        Print ("Commission = ",comms);
        
        if (Ticket>0){
       ExpertRemove();   
   
      }
}  
}

This is the whole code i use. As you can see it is very simple.
I do not have any problem loading the EA manually or with the EA removing itself after it has performed its function.
I absolutely make sure no EAs are active before I shut the system down.
What I can't understand is how the EA can possibly load itself onto any number of open charts when I start MT4.
Thank you for your help with this issue.

Any ideas?

  1. Once the EA start open new order, it remove itself.
  2. don't see any code that possibly load itself into any open chart (it literally impossible btw).
 

ExpertRemove() only gets called if OrderSend() is successful.

Try adding a print statement to handle failed OrderSends, and check your log.

 
Comments that do not relate to this topic, have been moved to "EA not opening orders".
Reason: