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

 
Christian Berrigan #: Yes I was aware that you already said that, and the premise of my post was trying to get history from OnInit() instead of OnCalculate(), which was accomplished.  It works really well.  I was so grateful to find the code in in the article I linked to above.  That guy's code worked phenomenally well, and now on any indicator where I need data from other timeframes I can do it reliably and without headaches.  He also gave ample warning in the article about not attempting to get data for the same timeframe as the indicator in this way, and his code checks for that circumstance as well.  Calculating the needed minimal date instead of calculating bars and trying to find the date from a bar solved the whole problem.
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!
 
Fernando Carreiro #:
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,

Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
  • www.mql5.com
Organizing Data Access - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Christian Berrigan #: 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?

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.

 
Fernando Carreiro #:

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 :)
 
Christian Berrigan #: 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.

 
Fernando Carreiro #:

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

Is it possible for a script to determine what input values are currently being used by an indicator on the same chart?
Is it possible for a script to determine what input values are currently being used by an indicator on the same chart?
  • 2022.05.27
  • www.mql5.com
Hello, I'm wondering if it is possible for a script to discover what input parameter values are currently being used by an indicator on a chart...
 
Christian Berrigan #: Thank you so much for your help on this Fernando.  You helped me out A LOT!!!

You are welcome!

Reason: