I am using a VPS to host my EA on Forex.com because when I tried to run the EA when the MT4 client was on my machine it would time out overnight and I'm trading off the London market, and the platform displayed GMT. Anyway my EA and indicator were aligned fine timewise with the client on my computer. But on the VPS which is also GMT, the time range that the indicator defines on the chart is 9 to 12 when the time range input to the indicator with extern variables is 4 to 7. I called Forex.com and was told the problem was that the "offset" setting in the code must be "0" . I did not write the code for the EA or the indicator, but I know enough about MQL4 to make some changes. The point is I cannot find anything regarding "offset" in the documentation on this site. The EA has no visual cues till a trade is made. I suppose could put some time displays in an alert, disable the trading ability and recompile, but I have no reason to believe the EA is reacting differently to time parameters than the indicatorr, which is also written in MQL4. Does anyone have any idea what is going on? Thanks
The setting is a function of the EA and your broker's server's time versus UTC/GMT. The time of the VPS is irrelevant. Usually it is what needs to be added to server time to get UTC/GMT.
Server time can be anything. IBFX in Denver uses GMT. Some servers in Europe use GMT+1 (I.E. local time.)
Google or Yahoo UTC time. They'll both show current time. Look at the current bar time (H1) on the terminal.
If the current time is 12:05 and server time is 11:00, you need to add one hour to get UTC. The parameter should be +1. (possibly -1 depending on how it's written.)
If the current time is 02:05 and the server time is 23:00, then you need to subtract three hours.
The setting is a function of the EA and your broker's server's time versus UTC/GMT. The time of the VPS is irrelevant. Usually it is what needs to be added to server time to get UTC/GMT.
Server time can be anything. IBFX in Denver uses GMT. Some servers in Europe use GMT+1 (I.E. local time.)
Google or Yahoo UTC time. They'll both show current time. Look at the current bar time (H1) on the terminal.
If the current time is 12:05 and server time is 11:00, you need to add one hour to get UTC. The parameter should be +1. (possibly -1 depending on how it's written.)
If the current time is 02:05 and the server time is 23:00, then you need to subtract three hours.
Then the offset is zero.I'm using a VPS through Forex.com. When I talked to them about it, they told me that the offset was 0. I understand this because it is GMT. But what is displayed by the indicator is in fact 5 hours later than the the time I entered into the extern variables of the EA. This is the server time, no? The range I entered into the EA was beginrange = "00:04" and endrange = "00:07". What shows up on the screen, or the servertime is "00:09" to "00:12". on other platforms where the client was local, like CMS and FXDD, it worked fine and what I entered into the extern variables was in fact displayed on the chart. Those too used GMT for servertime. So from the facts as I interpret them, there is something different with the servers. But what....???
Sounds like your indicator is programmed to display TimeLocal() instead of TimeCurrent().
Sounds like your indicator is programmed to display TimeLocal() instead of TimeCurrent().
There is 1 occurance of TimeCurrent() in the code and none of TimeLocal().........
I interpret 00:09 as 5 minutes not 5 hours later.
Show us the code where TimeCurrent intersects the EA variable.
I interpret 00:09 as 5 minutes not 5 hours later.
Show us the code where TimeCurrent intersects the EA variable.
Here is the code. But I do not think it is the EA. I think it is a function of the VPS non-local platform, because the display is server time or BDT and the time the EA accepts as an external variable must be 5 hours earlier. So if I want the range to be 5AM till 8AM London time I enter 00:00 to 00:03. Any other time I ran this code when the client was local, the exact time I put in the extern variables would be displayed on the screen.
extern int NumberOfDays = 150;
extern string periodBegin = "00:00";
extern string periodEnd = "03:00";
extern string BoxEnd = "16:00";
extern int BoxBreakOut_Offset = 0;
extern color BoxHLColor = Blue;
extern color BoxBreakOutColor = Gray;
extern color BoxPeriodColor = White;
void start() {
datetime dtTradeDate=TimeCurrent();
for (int i=0; i<NumberOfDays; i++) {
DrawObjects(dtTradeDate, "BoxHL " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxHLColor, 0, 1);
DrawObjects(dtTradeDate, "BoxBreakOut_High " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,2);
DrawObjects(dtTradeDate, "BoxBreakOut_Low " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,3);
DrawObjects(dtTradeDate, "BoxPeriod " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, periodEnd, BoxPeriodColor, BoxBreakOut_Offset,4);
dtTradeDate=decrementTradeDate(dtTradeDate);
while (TimeDayOfWeek(dtTradeDate) > 5) dtTradeDate = decrementTradeDate(dtTradeDate);
}
}
Here is the code. But I do not think it is the EA. I think it is a function of the VPS non-local platform, because the display is server time or BDT and the time the EA accepts as an external variable must be 5 hours earlier. So if I want the range to be 5AM till 8AM London time I enter 00:00 to 00:03. Any other time I ran this code when the client was local, the exact time I put in the extern variables would be displayed on the screen.
extern int NumberOfDays = 150;
extern string periodBegin = "00:00";
extern string periodEnd = "03:00";
extern string BoxEnd = "16:00";
extern int BoxBreakOut_Offset = 0;
extern color BoxHLColor = Blue;
extern color BoxBreakOutColor = Gray;
extern color BoxPeriodColor = White;
void start() {
datetime dtTradeDate=TimeCurrent();
for (int i=0; i<NumberOfDays; i++) {
DrawObjects(dtTradeDate, "BoxHL " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxHLColor, 0, 1);
DrawObjects(dtTradeDate, "BoxBreakOut_High " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,2);
DrawObjects(dtTradeDate, "BoxBreakOut_Low " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,3);
DrawObjects(dtTradeDate, "BoxPeriod " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, periodEnd, BoxPeriodColor, BoxBreakOut_Offset,4);
dtTradeDate=decrementTradeDate(dtTradeDate);
while (TimeDayOfWeek(dtTradeDate) > 5) dtTradeDate = decrementTradeDate(dtTradeDate);
}
}
I think the problem is in StrToTime() function which should be present in your code. I found the problem few days ago.
https://www.mql5.com/en/forum/126789
This function returns local PC time instead of MT4 server time.
I think the problem is in StrToTime() function which should be present in your code. I found the problem few days ago.
https://www.mql5.com/en/forum/126789
This function returns local PC time instead of MT4 server time.
Definately a source of bugs... don't know if I have the patience to write a conversion routine if given the offset in MT4 though...you'd think someone has already written one...
I think the problem is in StrToTime() function which should be present in your code. I found the problem few days ago.
https://www.mql5.com/en/forum/126789
This function returns local PC time instead of MT4 server time.
But then if I can find a way to input the complete time including year/date it would work........I think my head is going to explode........
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am using a VPS to host my EA on Forex.com because when I tried to run the EA when the MT4 client was on my machine it would time out overnight and I'm trading off the London market, and the platform displayed GMT. Anyway my EA and indicator were aligned fine timewise with the client on my computer. But on the VPS which is also GMT, the time range that the indicator defines on the chart is 9 to 12 when the time range input to the indicator with extern variables is 4 to 7. I called Forex.com and was told the problem was that the "offset" setting in the code must be "0" . I did not write the code for the EA or the indicator, but I know enough about MQL4 to make some changes. The point is I cannot find anything regarding "offset" in the documentation on this site. The EA has no visual cues till a trade is made. I suppose could put some time displays in an alert, disable the trading ability and recompile, but I have no reason to believe the EA is reacting differently to time parameters than the indicatorr, which is also written in MQL4. Does anyone have any idea what is going on? Thanks