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.
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
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().
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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 worksTo be honest, this is not exactly a true solution.
As a freelancer you have to keep your customer satisfied anyway.
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
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().