Is it possible to work with live ticks in MQL5 indicators?

 
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?
 
phade:
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?
Nope. OnCalculate will be called for each tick received.
 
phade: 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.

 
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...
 

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)

 
phade #: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.

 
phade #: I'd like to see a small example of a for loop capturing ticks in OnCalculate (nested for loop I'm guessing)

Look in the CodeBase. Here is one example ...

Code Base

Tick Chart

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.
 
Samuel Manoel De Souza #:
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...
As Fernando said. All ticks are processed by OnCalculate. There is no skipping as it is the case for OnTick.

Might be counter intuitive due to the naming, but that's how it is actually.
 
@Dominik Egert #: As Fernando said. All ticks are processed by OnCalculate. There is no skipping as it is the case for OnTick.

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.

 
Dominik Egert #:
As Fernando said. All ticks are processed by OnCalculate. There is no skipping as it is the case for OnTick.

Might be counter intuitive due to the naming, but that's how it is actually.

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

 
phade #: 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 .

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

30s Timeframe MA Cross EA - how do you pull tick data when you cant choose seconds in the enum_timeframes? - How to make an EA based on 30s timeframes?
30s Timeframe MA Cross EA - how do you pull tick data when you cant choose seconds in the enum_timeframes? - How to make an EA based on 30s timeframes?
  • 2022.11.06
  • www.mql5.com
Im a scalper so the 30s timeframe is great and i use tradingview, but i was wondering if there was a way to make an ea using those micro timeframes. How do you define that you want the mas to be on the 30s timeframe and for all trading to occur based on these 30s ma crosses