Download MetaTrader 5

stop EA from trading on a specific day [?]

To add comments, please log in or register
Nauris Mucenieks
839
Nauris Mucenieks 2015.04.21 00:44 

hi there, every body.


was wondering if any one could throw in a line of code to disable EA from trading on a specific day?

i, personally dislike fridays, so lets take that for example.

so, this is the code - it closes all trades, and restarts the EA if equity has grown.

so, my idea is - after trades have been closed - check if its friday - if no, it continues - if yes - Well.. it doesnt restart, but checks again (later or still on every tick).

anyone care to share?


big thanks!


void OnTick()
  {
  

    
  if(FLUSH){
  if(AccountEquity()>=(accountbalance/100*FLUSH_Percent)+accountbalance){
     first=true;
   nAll=nBuy=nSell=0;
   LastBuy=LastSell=0.0;
  close=CloseOrders();
        Print(" FLUSH ");



  accountbalance=AccountBalance();
  MagicNumber=MagicNumber+1;
  }}
Stuart Browne
5888
Stuart Browne 2015.04.21 01:03  
naurismucenieks:

hi there, every body.


was wondering if any one could throw in a line of code to disable EA from trading on a specific day?

i, personally dislike fridays, so lets take that for example.

so, this is the code - it closes all trades, and restarts the EA if equity has grown.

so, my idea is - after trades have been closed - check if its friday - if no, it continues - if yes - Well.. it doesnt restart, but checks again (later or still on every tick).

anyone care to share?


big thanks!


G'day

All you need to do is check the DayOfWeek (int) parameter. 0=Sunday through to 6=Saturday. So just chuck in something like this

 if(DayOfWeek()==5) return;   // Or whatever else you want to do if it's a Friday

 

Cheers 

Nauris Mucenieks
839
Nauris Mucenieks 2015.04.21 02:05  
Filter:

G'day

All you need to do is check the DayOfWeek (int) parameter. 0=Sunday through to 6=Saturday. So just chuck in something like this

 

Cheers 

hey there!


big thanks, works like a charm!

Stuart Browne
5888
Stuart Browne 2015.04.21 02:16  
naurismucenieks:

hey there!


big thanks, works like a charm!

Awesome! Happy to help :)
Aleksei Beliakov
25387
Aleksei Beliakov 2015.04.21 02:46  
damm i'll try to be faster))
Stuart Browne
5888
Stuart Browne 2015.04.21 03:36  
goverkms:
damm i'll try to be faster))
hehehehe
To add comments, please log in or register