- Is it possible to write an EA that not works based on ticks?
- multi currency in back test!
- A demo account as an indicator.
We know that OnTick() will not do anything in MT5 indicator scripts, and MqlTick is a structure based on tick retrieval (historic ticks, not live). I haven't worked with MQL4, but I believe it was possible to work with live ticks in mql4 indicators, but not mql5, is that correct?
There is nothing stopping you from processing real-time or historical tick data in an MQL5 indicator.
The OnCalculate() event handler is called on new tick events in the same way as the OnTick() event handler, on both MT5 and MT4.
Hm ok, but I thought OnCalculate is per-bar data. I assumed that to gather tick data, we have to go back in time until after a bar (of minimum 1 minute) has occurred. Let me know if I'm mistaken here, and if so, I'd like to see a small example of a for loop capturing ticks in OnCalculate (nested for loop I'm guessing)
No! OnCalculate is called on tick events, because the current close price is updated on every tick, even if its parameter data is "bar" based.
Look in the CodeBase. Here is one example ...
Vladimir Karputov, 2017.01.18 10:07
The indicator displays the Ask and Bid, which are taken from the real tick history. Also, it is possible to evaluate the spread changes by visually comparing the Ask and Bid.
OnTick and OnCalculate are not intended to process ticks one by one. Between each call of these functions may arrive many ticks. So if you want to work with ticks itself to calculate volume delta or something you need make use of the functions designed to retrive ticks data, which are CopyTick, CopyTickRange, SymbolInfoTick...
No, I did not say that it does not "skip" ticks. That is incorrect. What I said was that it processes "tick events".
It processes ticks in the same way as OnTick() and It DOES SKIP ticks if the processing takes too long.
I get this, but I'm asking about the retrieval of live ticks. Retrieval being the keyword here, I don't care about the background processing of ticks
I have already given you an example of just that, from the CodeBase, in my post #6.
That CodeBase publication serves as an example for both "live" and/or historical tick data. The process is the similar.
EDIT: I also shared my tick processing skeleton code in a different thread, which can do both historical and real-time tick processing (can also be used in indicators) ... https://www.mql5.com/en/forum/435832#comment_49133325
- 2022.11.06
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use