Cause EA to not trade if terminal is reopened?

 

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! 

 
Remove it from the chart before closing the terminal.
 
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.
 
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

 
Thanks!!!!
 

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()
}		
 
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?
 

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. 

 

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.

 

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? 

 

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? 

Reason: