Multi Time Frame Indicators Problem in Closed Market - page 2

 
Yashar Seyyedin #:

Thanks for sharing the solution.

To be honest, this is not exactly a true solution. Indicators need new ticks to update, and MTF indicators depend on a new tick. Closed market = no new ticks

It is a limitation that we have to live with because it's based on how the MT5 software works
 
It's possible, as I said, to create an MTF indicator that could work with the market closed, but it's a pretty large amount of code for not much. What's the point of seeing an indicator outside the market? Just wait for the first tick and everything will be fine.
 
Conor Mcnamara #:
To be honest, this is not exactly a true solution.

As a freelancer you have to keep your customer satisfied anyway.

 
if he pays a lot for the code, I can do it for him
 

or you could just remind the customer that trading is only possible on a live market, not on a closed market :')   next the customer will ask you do to a MACD plot on the chart window

 
Mohsen Farghadani:

Hi,

I have this sample code for the MTF RSI indicator.

The first thing we check in onCalculate is whether the number of bars calculated by the RSI handle matches the number of bars in the selected timeframe. If they don’t match, the function returns zero. This works well in the open market, and after a few ticks, we eventually calculate the RSI values.

However, in a closed market, onCalculate only runs once and does not calculate the historical values of the RSI.

Does anyone have a solution for this problem so that it works well in a closed market too?

Hi Mohsen

Create a class to access data using Timeseries access. Then you don’t need to use OnCalculate to receive market data. Use that class to feed your indicator calculation logic, and call your logic in OnInit().
Documentation on MQL5: Timeseries and Indicators Access
Documentation on MQL5: Timeseries and Indicators Access
  • www.mql5.com
These are functions for working with timeseries and indicators. A timeseries differs from the usual data array by its reverse ordering - elements...
 
Yes, it's the right logic, but it requires a lot of work just to have an off-market indicator.