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
Maybe I am not using the right search terms in google or on this forum (if so, please enlighten me so I can find the golden key). I cannot find easy solutions to aligning my timezone with my broker's timezone in the strategy tester... and take into account DST. So, I kludged my way through it as best I could. Find below/attached my chonky fix. Feel free to adapt it if it works for you, I'd love to see anyone's suggestion for improvements. I know I would like to make it a little more atomic, and see if I could make the code more efficient, but at least this is working "good enough" for my current purposes. Except it feels kludgey.
The main return value is: Is it time to trade (bool). True for trade, false for don't trade (outside of your prescribed hours). Should work in a live EA as well as in the strategy tester. Note that I don't mind using "approximate" DST start and end dates in my testing. You might.
It should compile and work in mt4 and 5.
There is one important setting that you need, and that you can run this EA on a chart to find out: the ServerOffset value. Mine, for instance is -7 showing the diff between US Eastern and the MetaQuotes server on MT5. You can use the value you find for this if you incorporate this code into your own project. All mistakes are my own - either by being negligent in copy/pasting some tidbits from other sources, or in my own lack of coding acumen.
Cheers