Thread: Ask!
View Single Post
  #1092 (permalink)  
Old 05-15-2008, 06:59 AM
FerruFx FerruFx is offline
Senior Member
 
Join Date: Feb 2007
Posts: 881
FerruFx is on a distinguished road
Quote:
Originally Posted by sonicdeejay View Post
How can I write a code to make the EA not to trade during certain period (e.g 01:00 GMT 0 - 06:00 GMT 0), even there is a buy/sell signal??
Here's a way to code a time filter:

Quote:
extern bool Use.Time.Filter = false;
extern string Server.Time.To.Start = "00:00";
extern string Server.Time.To.Stop = "00:00";

datetime start_time,end_time;
Then:

Quote:
//---- Time period calculation
start_time = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + Server.Time.To.Start); //---- Date and time to start
end_time = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + Server.Time.To.Stop); //---- Date and time to stop

//---- Is it time to trade
if(Use.Time.Filter && (TimeCurrent() < start_time || TimeCurrent() >= end_time)) return(0);
FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
Reply With Quote