Getting date of a bar from history (not from indicator data that is not-yet loaded) Alternative to iTime() (which requires data loaded) - page 2
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
Well, if you insist in doing things in a convoluted way, that adds extra bloat to your code, who am I to correct you. I wish all the best in your coding!
Honest question:
Given the goal of reliably acquiring data from other timeframes in an indicator without waiting for xxx number of calls from OnCalculate() (waiting for multiple ticks) until the other timeframe data is finally loaded, and if that is a convoluted approach, then what is the purpose of this article?
https://www.mql5.com/en/docs/series/timeseries_access
I'm honestly wondering why waiting for xxx number of ticks before finally having the needed data is a better approach?
Thanks again,
Given the goal of reliably acquiring data from other timeframes in an indicator without waiting for xxx number of calls from OnCalculate() (waiting for multiple ticks) until the other timeframe data is finally loaded, and if that is a convoluted approach, then what is the purpose of this article? https://www.mql5.com/en/docs/series/timeseries_access
I'm honestly wondering why waiting for xxx number of ticks before finally having the needed data is a better approach?
The documentation you referenced is valid, but it requires context. What is not valid, is doing it all in the OnInit(). There is no such example of that in the reference documentation for a reason.
Doing it in the OnInit() and not releasing it until you are done, will hold up all other Indicators on the same symbol, because they all run on the same thread.
Indicator
One thread for all indicators on a symbol. The number of threads is equal to the number of symbols with indicators
An infinite loop in one indicator will stop all other indicators on this symbol
Instead, you should be doing it asynchronously, in OnCalculate(), releasing the context while you wait, so that you don't freeze everything up. Doing so, also simplifies the approach, making it more streamlined and less convoluted.
PS! Also, no one said that you have to wait x number of ticks in OnCalculate before you access other symbol's data, but you should wait for at lease one tick on the current symbol, if you plan to use the current symbol data as well.
EDIT2: Also, as a comparison, deciding to use an Indicator with just the OnInit() doing most of the job, and not requiring OnCalculate(), then you might as well just use a Script instead which runs on a separate thread, or depending on the functionality, a Service may also be applicable, or even an EA if it be the case.
The documentation you referenced is valid, but it requires context. What is not valid, is doing it all in the OnInit(). There is no such example of that in the reference documentation for a reason.
Doing it in the OnInit() and not releasing it until you are done, will hold up all other Indicators on the same symbol, because they all run on the same thread.
Instead, you should be doing it asynchronously, in OnCalculate(), releasing the context while you wait, so that you don't freeze everything up. Doing so, also simplifies the approach, making it more streamlined and less convoluted.
PS! Also, no one said that you have to wait x number of ticks in OnCalculate before you access other symbol's data, but you should wait for at lease one tick on the current symbol, if you plan to use the current symbol data as well.
EDIT2: Also, as a comparison, deciding to use an Indicator with just the OnInit() doing most of the job, and not requiring OnCalculate(), then you might as well just use a Script instead which runs on a separate thread, or depending on the functionality, a Service may also be applicable, or even an EA if it be the case.
Excellent information -- I appreciate it. Out of curiosity, do you happen to know if a person had two charts open for the same symbol, would one offending indicator on one of the charts freeze indicators on both charts (as they both have the same symbol), or just freeze all the indicators on the one chart with the offending indicator?
Not that it changes the point that you made, but I am always curious to know how things work.
Thanks!
EDIT: Nevermind. The question is answered in literally the first sentence of the article you linked to :)Yes, as stated, ALL indicators for the same symbol, no matter on what chart, will suffer. Also, based on experience, the charts themselves also suffer, but that is not mentioned in the documentation.
Yes, as stated, ALL indicators for the same symbol, no matter on what chart, will suffer. Also, based on experience, the charts themselves also suffer, but that is not mentioned in the documentation.
Thank you so much for your help on this Fernando. You helped me out A LOT!!!
Wondering if you could visit this quick question on a new post. I'm sure you have the answer as part of your common knowledge.
https://www.mql5.com/en/forum/425985
You are welcome!