Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
- Never user any trading or symbol related functions in OnInit(). That handler is strictly for initialisation and there are no guarantee that connection as well established by then. Wait for the first new tick event before processing anything related to the data feed, contract specifications or trading. So, please correct your example code and try it again.
- The OnTick() event handler will not be called for every new tick event. Until it returns, no new tick events are queued for process. In other words it can easily skip ticks.
- Time millisecond timestamp on tick data is not unique. You can easily have multiple ticks during the same millisecond timestamp.
- Please inform us of which modelling method you are using—"Every tick" or "Every tick based on real ticks"?
Hi Fernando!
Thank you a lot, you are 100% correct!
The issue was on the EA Strategy Tester, I thought I was using "Every tick based on real ticks", I set to that but it got back to "Every tick" and I'm not sure how.
Changing back to "Every tick based on real ticks" fixed the issue, now the Ticks from the EA are exactly like the ones returned from CopyTicksRange().
Thank you!
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
Hello!
I'm creating an EA primarily using OnTick() and to confirm it's working properly I was using CopyTicksRange() to double check the results.
The issue was that they were diverging and upon further investigation I noticed that the Ticks from one are completely different from the other, even from the same period.
I took a 1 sec timeframe from a random day and printed all the Ticks from both functions.
EA:
I tried the following code on the OnInit() from the EA but it came empty, so I used an Indicator:
The results from the EA:
The results from the Indicator:
Why are they so different? In both amount and values?
I would understand if the OnTick() was an average of all Ticks inside that second, but there's no direct correlation! Bid is 5 points different and Ask 9~10 points.
Am I fetching the values wrong? Am I missing something?
So why are they so different and which one is more precise? If I have to pick one to get the best results, which one should I use?
Thank you in advance!