time filter

 

i use ea with martingal and i wana using time filter just for FirstOrder no for other trades .. some onecan help me..


******************************************

extern bool UseTimeFilter=true;

extern bool MON = TRUE;

extern bool TUE = TRUE;

extern bool WED = TRUE;

extern bool THU = TRUE;

extern bool FRI = TRUE;

extern bool SAT = TRUE;

extern bool SUN = TRUE;

extern string HOURS_2TRADE_FROM = "03:00";

extern string HOURS_2TRADE_TO = "21:00";

************************************************

void OnTick()


 {

if ( UseTimeFilter && TimeFilter(HOURS_2TRADE_FROM,HOURS_2TRADE_TO)==true){

 

TS()<1;TB<1;


 }


TS() > 1;TB>1;

 }





*******************

 void WEEKDAYS_2TRADE() {

   if ((MON && DayOfWeek() == 1) || (TUE && DayOfWeek() == 2) || (WED && DayOfWeek() == 3) || (THU && DayOfWeek() == 4) || (FRI && DayOfWeek() == 5) || (SAT && DayOfWeek() == 6) || (SUN && DayOfWeek() == 0)) HOURS_2TRADE()  ;

}



 

 void HOURS_2TRADE() {

   int TimeTradeServer = TimeCurrent();

   int HOURS = TimeHour( TimeTradeServer );


 

}







bool TimeFilter(string Sh, string Eh){


datetime Start = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) +""+Sh);


datetime End = StrToTime(TimeToStr(TimeCurrent(),TIME_DATE) +""+Eh);


if(!(Time [0]>=Start &&Time[0]<=End)){


return(false);

}

return (true);


}




 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019.05.06)
              Messages Editor

  2. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum (2015.02.11)

    Why it won't work:
              Calculate Loss from Lot Pips - MQL5 programming forum (2017.07.11)
              THIS Trading Strategy is a LIE... I took 100,000 TRADES with the Martingale Strategy - YouTube

  3. TS()<1;TB<1;
     }
    TS() > 1;TB>1;

    What is this bable?

  4. ALI AMRIOUI: wana using time filter just for FirstOrder no for other trades .. some onecan help me..

    Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help (2017.04.21)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018.05.12)

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help (2017.04.21)

 
William Roeder:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019.05.06)
              Messages Editor

  2. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum (2015.02.11)

    Why it won't work:
              Calculate Loss from Lot Pips - MQL5 programming forum (2017.07.11)
              THIS Trading Strategy is a LIE... I took 100,000 TRADES with the Martingale Strategy - YouTube

  3. What is this bable?

  4. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help (2017.04.21)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018.05.12)

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help (2017.04.21)

i wana using time filter just for the FirstOrder coz i use hedge  martinagal .. means if i have trade open should ea work even timefilter is activated 

 
extern bool UseTimeFilter=true;
extern bool MON = TRUE;
extern bool TUE = TRUE;
extern bool WED = TRUE;
extern bool THU = TRUE;
extern bool FRI = TRUE;
extern bool SAT = TRUE;
extern bool SUN = TRUE;
extern string HOURS_2TRADE_FROM = "03:00";
extern string HOURS_2TRADE_TO = "21:00";



void OnTick()

 {

if ( UseTimeFilter && TimeFilter(HOURS_2TRADE_FROM,HOURS_2TRADE_TO)==true){
 


 TS()<1;TB()<1;
 }
 TS()>1;TB()>1;

}




  void WEEKDAYS_2TRADE() {
   if ((MON && DayOfWeek() == 1) || (TUE && DayOfWeek() == 2) || (WED && DayOfWeek() == 3) || (THU && DayOfWeek() == 4) || (FRI && DayOfWeek() == 5) || (SAT && DayOfWeek() == 6) || (SUN && DayOfWeek() == 0)) HOURS_2TRADE()  ;
}


 
 void HOURS_2TRADE() {
   int TimeTradeServer = TimeCurrent();
   int HOURS = TimeHour( TimeTradeServer );

 
}






bool TimeFilter(string Sh, string Eh){

datetime Start = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) +""+Sh);

datetime End = StrToTime(TimeToStr(TimeCurrent(),TIME_DATE) +""+Eh);

if(!(Time [0]>=Start &&Time[0]<=End)){

return(false);
}
return (true);

}
Reason: