- Converting from mql4 to mql5
- OnTick() time
- Managing optimization processes in real time and transferring massive data from the agents to MetaTrader 5
You should not use TimeCurrent() in OnInit(), only in OnTick(). However, TimeCurrent() is the simulated trade server time, not the current local time.
You should not use TimeCurrent() in OnInit(), only in OnTick(). However, TimeCurrent() is the simulated trade server time, not the current local time.
Show your code sample. Otherwise we can't identify what you are doing incorrectly.
You don't have to provide all yout code. Male a small test code to demonstrate the problem you are having.
Show your code sample. Otherwise we can't identify what you are doing incorrectly.
You don't have to provide all yout code. Male a small test code to demonstrate the problem you are having.
- Please use "</>" or Alt-S when adding code to your posts.
- Please provide proper code, that compiles, and in this case, that can be optimised (needs inputs).
- Initialise your global variable to a predictive value (e.g. WRONG_VALUE).
Please test optimisations on the following code and show us the log output.
input int i_nTest = 0; datetime dtTime = WRONG_VALUE; void OnTick() { dtTime = TimeCurrent(); }; void OnTesterPass() { Print( "OnTesterPass: ", dtTime ); }; double OnTester() { Print( "OnTester: ", dtTime ); return 0; };
Also, I've never used the OnTesterPass event handler, so I am not sure when it is called, if before or after the actual pass. Your results from the previous code should help identify that.
I have modified your code, so it returns value onTesterPass. Please see the screenshots. It return wrong value for the dtTime
Also, I've never used the OnTesterPass event handler, so I am not sure when it is called, if before or after the actual pass. Your results from the previous code should help identify that.
I also tried to convert dtTime into double so I can pass the array into FrameAdd, but it still return wrong datetime.
Then OnTesterPass() is being called BEFORE any OnTick events, just as I suspected, so you will not be able to collect data about the Test Date Range this way.
You may need to use the OnTester() instead, but you will need to output to a File as it seems that you cannot Print() from OnTester() either.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use