You could input your times as decimals. Instead of 9:30, input 9.30 as a double.
//Global input double LondonStart=9.30; input double LondonEnd=11.30; int LondonStartHour=(int)MathFloor(LondonStart); int LondonStartMinutes=(int)((LondonStart-LondonStartHour)*100); int LondonStartSeconds=LondonStartHour*3600+LondonStartMinutes*60; int LondonEndHour=(int)MathFloor(LondonEnd); int LondonEndMinutes=(int)((LondonEnd-LondonEndHour)*100); int LondonEndSeconds=LondonEndHour*3600+LondonEndMinutes*60; //In main code datetime today_midnight=TimeCurrent()-(TimeCurrent()%(PERIOD_D1*60)); datetime London_open=today_midnight+LondonStartSeconds; datetime London_close=today_midnight+LondonEndSeconds; if(TimeCurrent()>=London_open && TimeCurrent()<London_close) { //do something }
GumRai:
thanks,man.you saved me from a lot of hassle.
You could input your times as decimals. Instead of 9:30, input 9.30 as a double.
//Global input double LondonStart=9.30; input double LondonEnd=11.30; int LondonStartSeconds; int LondonEndSeconds; //init int LondonStartHour=(int)MathFloor(LondonStart); int LondonStartMinutes=(int)((LondonStart-LondonStartHour)*100); LondonStartSeconds=LondonStartHour*3600+LondonStartMinutes*60; int LondonEndHour=(int)MathFloor(LondonEnd); int LondonEndMinutes=(int)((LondonEnd-LondonEndHour)*100); LondonEndSeconds=LondonEndHour*3600+LondonEndMinutes*60; //Main Code datetime today_midnight=TimeCurrent()-(TimeCurrent()%(PERIOD_D1*60)); datetime London_open=today_midnight+LondonStartSeconds; datetime London_close=today_midnight+LondonEndSeconds; if(TimeCurrent()>=London_open && TimeCurrent()<London_close) { //do something }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
but the problem is it trades from 9:00 to 9:30,then 10:00 to 10:30.
then i used the following code
but am trying to input LondonOpen=9:30,it is showing error.
Please Advice.