Error 4806 on closed market (with no new ticks)

Hello,

my MTF (multi-timeframe) indicator works fine on opened market (when new ticks are received -> starting OnCalculate() function).

E.g.: I see D1 moving average values on 10min chart…

Problem is on the closed market where no new ticks are received. I get error 4806 (BarsCalculated function returns 0).

If I change chart period to D1 it works fine. It seems like OnCalculate() function in called indicator.ex5 is not started without new tick on different time-frame from D1?

Here is summary how I call the D1 indicator in my MTF indicator:

handle=iCustom(NULL,PERIOD_D1,"indicator.ex5",parameter);
.
.
.
calculated=BarsCalculated(handle);  //returns 0 on closed market with time-frame different from D1 !!!

Did you checked your handle is valid ?

What is the returned value of OnCalculate() for indicator.ex5 ?

ERR_INDICATOR_DATA_NOT_FOUND

4806

Requested data not found

I don’t when this error eccours, but if you get this error then handle it in your code (best way is to simply return).

I printed handles and both (handle in MTFindicator.ex5 and handle in indicator.ex5) return 10.

OnCalculate() in indicator.ex5 returns 2450 (D1 rates total) even on closed market.

OnCalculate() in MTFindicator.ex5 returns nothing on closed market, due to the mentioned error 4806. After the new tick is received it returns 24500 (M20 rates total).

Is It not possible to get values from indicator.ex5 on different time-frame without tick update? Or do I need to use OnTimer somehow?

Thnaks

Sorry but I don’t understand your issue. If your indicator.ex5 returns 2450 then BarCalculated must return 2450. Maybe it would be more easy if you can show your code.

Hi,

I am using the same code as in this tutorial https://www.mql5.com/en/articles/127

The only difference is calling custom indicator with different time-frame from PERIOD_CURRENT

Handle=iCustom(_Symbol,PERIOD_D1,"TSIs",r,s,sp,sm);

This article don’t talk about multi timeframe indicator. I doubt it can work by changing only this line of code.

Of course I know, but the same approach is used for the most of MTF indicators:
(https://www.mql5.com/en/code/198)

(https://www.mql5.com/en/code/1757)

(https://www.mql5.com/en/code/177)

None of them are able to show values on closed market and must wait for a new tick!

All of them shows the error 4806 on closed market (e.g.: Set time-frame to H1 and put indicator on 15min chart).