Not Alerting if Account was changed

Back to topics list To post a new topic, please log in or register
avatar
26
bunnycat 2016.05.12 05:47
 

Hey, so I call a function on order close, but I want the alert to not be triggered if I change accounts.  So for instance, I have an order open in an account, then switch to the demo, I don't want my custom alert function to trigger.


This is the end of the main EA code:

if (Orders>OrdersTotal()) {  
      
      AlertOrder(maxlots);
      Orders=OrdersTotal();
      return;      
      
      }
      
      Orders=OrdersTotal();

 I tried putting "Orders = 0" in OnDeInit, but that didn't solve it.  AlertOrder still gets called if i change accounts.  

 Any idea how to fix it?  Thanks in advance!

avatar
69
Tecuciztecatl 2016.05.12 10:34 #
 

Use ACCOUNT_LOGIN:

/// on init
if (login==0) login=AccountInfoInteger(ACCOUNT_LOGIN);
if (login!=AccountInfoInteger(ACCOUNT_LOGIN))
   {
   login=AccountInfoInteger(ACCOUNT_LOGIN);
   // new account
   }
avatar
26
bunnycat 2016.05.12 18:33 #
 

Thanks so much!!! Works great!!!

avatar
13001
WHRoeder 2016.05.12 19:15 #
 
Or just check for it directly: if(  UninitializeReason() == REASON_ACCOUNT )
avatar
69
Tecuciztecatl 2016.05.12 20:09 #
 
WHRoeder:
Or just check for it directly: if(  UninitializeReason() == REASON_ACCOUNT )
Yes, I looked at this, but this phrase confused me: "...or reconnection to the trade server has occurred due to changes in the account settings"
avatar
26
bunnycat 2016.05.12 22:56 #
 

hmm, yeah, even simpler, but I wonder about what Tecuciztecatl brought up.  What do you think falls into that category?

Thanks both of you! 

avatar
13001
WHRoeder 2016.05.13 14:08 #
 
bunnycat: What do you think falls into that category?
  1. Confusion, false assumptions, misreading, mis-translations.
  2. Instead of trying a actual test to find out.
bunnycat:
if (Orders>OrdersTotal()) {  
      
      AlertOrder(maxlots);
      Orders=OrdersTotal();
      return;      
      
      }
      
      Orders=OrdersTotal();
No OrderSelect loop with filtering means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
Back to topics list  

To add comments, please log in or register