problem with month - day condition

 

i should stop trading between dec15 and jan15, but in BT nothing gets blocked ... what is wrong?

if (Month()==12 && Day()>=15 || Month()==1 && Day()<=15) return(0);
 
fulltilt:

i should stop trading between dec15 and jan15, but in BT nothing gets blocked ... what is wrong?

Print the values of Month() and Day() to see if they are correct . . . alternatively . . .

Try using TimeMonth( TimeCurrent() ) and TimeDay( TimeCurrent() )

 
RaptorUK:

Print the values of Month() and Day() to see if they are correct . . . alternatively . . .

Try using TimeMonth( TimeCurrent() ) and TimeDay( TimeCurrent() )


thank you, now it's working :-)
 
fulltilt:

i should stop trading between dec15 and jan15, but in BT nothing gets blocked ... what is wrong?

if (Month()==12 && Day()>=15 || Month()==1 && Day()<=15) return(0);
  1. What is the priority between && and ||? If you don't know (and you shouldn't rely on it anyway) then make it explicit
    if ( (Month()==12 && Day()>=15) || (Month()==1 && Day()<=15) ) return(0);

  2. You using the tester, you don't want the CURRENT month/day which is now April. You want the BAR's month/day. Use TimeMonth(Time[0])/TimeDay(Time[0])
    Ref: https://www.mql5.com/en/forum/127483 reports DayOfWeek() always returns 5 in the tester.