Trading certain days of the week

 

Hi


I am trying to allow my EA to have the ability to trade on either Monday, Midweek (tu,we,th) or Friday. Or possibly a combination


I created 3 boolean values with midweek set as true as a default:-

extern bool Mon                     = false;
extern bool Midweek              = true;
extern bool Fri                        = false; 

Then code as follows.

int start()

{

if (Mon==False && DayOfWeek()==1) // Lets not trade on monday
{
      //Alert("No Trading on Monday");   // Message to the trader
     }

   return(0);
   
 if (Midweek==false && DayOfWeek()>1 && DayOfWeek()<5 ) // Lets not trade Midweek
{
      Alert("No Trading Midweek");   // Message to the trader
     }
 
   return(0);  
   
 if (Fri==False && DayOfWeek()==5) // Lets not trade on Friday
{
      //Alert("No Trading on Friday");   // Message to the trader
     }

   return(0);  

If i start the EA on a Monday i get the alert no trading, however in the strategy tester it gives no results if the 3 boolean values are set in any configuration.

I obviously have made a fundamental error. Can anyone point me in the right direction please?


Thanks

Neil

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
 
Please edit your post and
use the code button (Alt+S) when pasting code

 

This makes your EA return after the first comparison, without further action.

if (Mon==False && DayOfWeek()==1) // Lets not trade on monday
{
      //Alert("No Trading on Monday");   // Message to the trader
     }

   return(0);

Probably you wanted to have the return inside the braces.

 
lippmaje:

This makes your EA return after the first comparison, without further action.

Probably you wanted to have the return inside the braces.

Aha

Of course well spotted.

Thanks will give it a go.

Regards


Neil

Reason: