Download MetaTrader 5

pls help me add start and stop trade time

To add comments, please log in or register
Akintunde Akintinoye
322
Akintunde Akintinoye  
pls i want to add
DeanDeV
330
DeanDeV  
akintinoyea:
pls i want to add
Post your code.
whroeder1
15321
whroeder1  
learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
Sherif Hasan
7378
Sherif Hasan  
DeanDeV:
Post your code.
extern int HoursFrom = 10;
extern int HoursTo = 20;

int start()
{
int datetime = TimeCurrent();
int hour = TimeHour(datetime);
    
if ((HoursFrom < HoursTo && hour >= HoursFrom && hour < HoursTo) ||
    (HoursFrom > HoursTo && (hour < HoursTo || hour >= HoursFrom)))
    {  
     //Do**** 
    }
    
}
JD4
1101
JD4  
I didn't realise you were the one with the problem sheriff.  (:P )
Keith Watford
Moderator
10376
Keith Watford  

sheriffonline:

extern int HoursFrom = 10;
extern int HoursTo = 20;

int start()
{
int datetime = TimeCurrent();
int hour = TimeHour(datetime);
    
if ((HoursFrom < HoursTo && hour >= HoursFrom && hour < HoursTo) ||
    (HoursFrom > HoursTo && (hour < HoursTo || hour >= HoursFrom)))
    {  
     //Do**** 
    }
    
}

 



 I wouldn't think that would compile using datetime as a variable name

extern int HoursFrom = 10;
extern int HoursTo = 20;

int start()
{
int hour = TimeHour(TimeCurrent());
    
if ((HoursFrom < HoursTo && hour >= HoursFrom && hour < HoursTo) ||
    (HoursFrom > HoursTo && (hour < HoursTo || hour >= HoursFrom)))
    {  
     //Do**** 
    }
    
}

 You can do away with that line altogether

DeanDeV
330
DeanDeV  
sheriffonline:

double StartTime=X;
double FinishTime=Y;

if(Hour()>=StartTime && Hour()<=FinishTime)
 {

 }
whroeder1
15321
whroeder1  
DeanDeV:
double StartTime=X;
double FinishTime=Y;

if(Hour()>=StartTime && Hour()<=FinishTime)
 {

 }
Sorry Dean but that fails if you want to run over midnight (start 1800 end 0200) GumRai has it right.
To add comments, please log in or register