![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Where did you put the functions, that I provided a link to TWICE? (In #2 and #5).
You could post the links another hundred times but yet i think its painfully obvious i'd be no nearer to understanding how to solve the issue. As far as i can tell you've posted numerous functions on those links and i have no clear idea which relate to my project, and better still all the ones I've tried seem to return a whole bunch more errors, which is why i modified my code in the first place.
Clearly, i'm very new to coding in MQL5, and clearly i have a long way to go. If you don't want to help then its completely understood, but circle jerking me with links (that i had already mentioned i didn't understand in my FIRST reply to you), helps nobody.
Hi Lorentzos, thanks for your detailed explanation. Reading it however makes me think i'm perhaps looking at the back testing data incorrectly..
To be fully clear on my issue; i am trying to back test my strategy, and it needs to trade within the window 9:30am-9:45am UTC-5. I am currently in UTC+4, and my broker provides data UTC+2.
I guess the question is, when running a back test where does the data come from? Is it provided by MetaTrader in local times to the market/symbol, or does it come from my broker? I.e. to run a back test on the US30.Cash will i need to adjust the code you provided to local UTC-5 times (i.e. its provided from my broker and therefore DST will also need to be adjusted for), or can i code it as you describe and it will understand it is for the UTC-5 timezone because that's the timezone of the market (US30)?
A bit wordy but hopefully that's clear..?
Hmm yeah i see .
So you will need to adjust your trading window for the DST . I imagine a timezone shift changes the "range" of an event , if i'm not mistaken.
The Tester holds the broker time and you can turn that into your time with an offset (and set the offset to 0 and use local time when running the program live)
The DST though remains .
There could be a solution if it can return the gmt time then (in the test) which means with a couple of tweaks on the trading window
you would be set , although very vigilant to test right times and operate on right times.
Hmm yeah i see .
So you will need to adjust your trading window for the DST . I imagine a timezone shift changes the "range" of an event , if i'm not mistaken.
The Tester holds the broker time and you can turn that into your time with an offset (and set the offset to 0 and use local time when running the program live)
The DST though remains .
There could be a solution if it can return the gmt time then (in the test) which means with a couple of tweaks on the trading window
you would be set , although very vigilant to test right times and operate on right times.
Urgh well that's a massive pain. I'd actually already cracked the trading window issue with my original code (adjusted from William's suggestion, and by cracked i mean for if i was in the local time zone - its useless outside of it :/), although i have little doubt that your's is better than anything i've come up with thus far. I think my only option is to continue back testing in prorealcode (which handles all time zones issues for you) and just use MQL5 for execution.
On that note, would you happen to see any obvious flaws in my code (the long "full" code i posted) that would prevent it from executing any orders? Even if the time zone issue is still a mess, i would have thought it would do some trades in a back test (even though the results would be meaningless!) yet it doesn't do a single one, regardless of the time period i test it over.
TIA
Urgh well that's a massive pain. I'd actually already cracked the trading window issue with my original code (adjusted from William's suggestion), although i have little doubt that your's is better than anything i've come up with thus far. I think my only option is to continue back testing in prorealcode (which handles all time zones issues for you) and just use MQL5 for execution.
On that note, would you happen to see any obvious flaws in my code (the long "full" code i posted) that would prevent it from executing any orders? Even if the time zone issue is still a mess, i would have thought it would do some trades in a back test (even though the results would be meaningless!) yet it doesn't do a single one, regardless of the time period i test it over.
TIA
It can be done actually this way
But yeah it would be really handy if the rates had a time_gmt component that is true.
Edit :
Looking at your code i set the Lot to 0.01 and the symbol to EURUSD for a test
Make sure you are running on a timeframe that can "render" or "enter" your time window , i tested on M1
And additionally the time check is not working
replace it with this : (after you include the new function in the code)
Set the example prints to false because they are annoying too .
Enjoy
😊
It can be done actually this way
But yeah it would be really handy if the rates had a time_gmt component that is true.
By time shift days are you referring to the days when the clocks go back/forward? If so then i think that's where i tap-out. I tend to back test on many different time periods, use walk forward analysis etc and so if i have to faff about coding in each DST change it's just going to be more hassle than i have the motivation or, frankly, the technical no-how to do.
It seems like its a rather gaping floor in the software however to not provide an easier method to adjust for this, assuming i'm not the only person in the world trying to back test data from a different time zone of course. Being new to it i don't know but am assuming its primarily used for execution as opposed to back testing?
It can be done actually this way
But yeah it would be really handy if the rates had a time_gmt component that is true.
Edit :
Looking at your code i set the Lot to 0.01 and the symbol to EURUSD for a test
Make sure you are running on a timeframe that can "render" or "enter" your time window , i tested on M1
And additionally the time check is not working
replace it with this : (after you include the new function in the code)
Set the example prints to false because they are annoying too .
Enjoy
😊
By time shift days are you referring to the days when the clocks go back/forward? If so then i think that's where i tap-out. I tend to back test on many different time periods, use walk forward analysis etc and so if i have to faff about coding in each DST change it's just going to be more hassle than i have the motivation or, frankly, the technical no-how to do.
It seems like its a rather gaping floor in the software however to not provide an easier method to adjust for this, assuming i'm not the only person in the world trying to back test data from a different time zone of course. Being new to it i don't know but am assuming its primarily used for execution as opposed to back testing?
Yeah , all it had to have was keep a gmt copy of time which maybe it does and a more experienced coder will mention it , but so far i have not seen it
ah great i'll give it a go! don't expect a hasty response however, i'll likely be hacking around at it until tomorrow some time (i wish i were joking)
Great . Good evening
Great . Good evening
Hi Lorentzos, finally got around to trying out your code and low and behold i again can't seem to get it to work again.. To be completely clear the exact code i am trying is below, and i am testing on EURUSD with 0.1 lot size and M1 bars as suggested.
Would you mind trying the code yourself and seeing if it produces trades? At this point i'm starting to think there is a configuration setting wrong in my MT5 as i just cant see how it would not work.. *weep*