Download MetaTrader 5

Cause EA to not trade if terminal is reopened?

To add comments, please log in or register
Deposit to your account in any convenient way. There are 4 of them here!
bunnycat
75
bunnycat 2016.03.24 20:18 

Hi, when I reopen my terminal, sometimes I am getting unwanted trades based on settings from when I was using the EA in a prior terminal session.

How can I prevent EA from trading when I first open the terminal until I actually manually reattach it to the chart? 

Thanks in advance! 

whroeder1
14519
whroeder1 2016.03.25 13:11  
Remove it from the chart before closing the terminal.
bunnycat
75
bunnycat 2016.03.25 22:34  
That works if I remember, but I stand to lose money if I forget.  Any idea how to do this anyone?  Just want EA to not trade if the terminal has been closed until I reattach.
Keith Watford
Moderator
9623
Keith Watford 2016.03.25 22:44  
bunnycat:
hah yeah, obviously that works!!!  But if I forget I can lose money... Any simple fix?
  if(reason==REASON_CLOSE)
    ExpertRemove();

put in OnDeinit

bunnycat
75
bunnycat 2016.03.26 01:30  
Thanks!!!!
bunnycat
75
bunnycat 2016.03.27 21:20  

Hey, actually , I'm not sure how to get t.  I have the following, but it's not removing it when I close the terminal.  Thanks in advance.

 

void OnDeinit(const int reason){
  
//----

   if(reason==REASON_CLOSE){
   ExpertRemove()
}		
Keith Watford
Moderator
9623
Keith Watford 2016.03.27 22:26  
bunnycat:

Hey, actually , I'm not sure how to get t.  I have the following, but it's not removing it when I close the terminal.  Thanks in advance.

 

Have you added it in the EA that you want to remove?
bunnycat
75
bunnycat 2016.03.28 03:54  

Yeah, should that be enough?  It doesn't seem to work, have it exactly like this:

 

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason){
  
//----

   if(reason==REASON_CLOSE){
   ExpertRemove();
}

   
   Comment("");
//----
   
  }

 

any ideas?  Thanks in advance... seems like a great solution, but don't know why it's not working. 

Keith Watford
Moderator
9623
Keith Watford 2016.03.28 04:23  

I don't know why it isn't working either.

Are you actually closing the terminal? It may not work if you simply shut down your computer without closing the terminal first.

bunnycat
75
bunnycat 2016.03.28 04:33  

Hey, you know I'm testing it right now.  If I set the reason to 3, which is Chart change, the expert removes just by changing the time frame, but if I use 9 it doesn't work.  I'm just clicking the X at the top right of the terminal.   I think that's what we mean right? 

 

Does this ever work?  I wonder if clicking the X just closes the terminal before the OnDeInit function actually runs? 

bunnycat
75
bunnycat 2016.03.28 04:37  

hmm, and for what it's worth, "file -->> exit" doesn't work either

 

Is there another simple way to do this with a global variable or something? 

12
To add comments, please log in or register