problem persists with indicator not working in closed market.

 

This indicator loads properly when applying the single time frame mode(use alternate resolution=false)


But when applying (use alternate resolution=true) it won't work in closed market. But works properly with strategy tester.

Files:
 

The problem seems to be OnCalculate is called before the initiation of indicator in OnInit finishes.

But solution I do not know what can be.

I tried putting initiation line in OnCalculate but it didn't help.

Also I tried calling OnCalculate several times but it didnt help.

Also I tried using fake waiting loops to wait a bit to make sure everything is loaded but it also didnt help. 

 
Yashar Seyyedin #: The problem seems to be OnCalculate is called before the initiation of indicator in OnInit finishes. But solution I do not know what can be. I tried putting initiation line in OnCalculate but it didn't help.

Also I tried calling OnCalculate several times but it didnt help. Also I tried using fake waiting loops to wait a bit to make sure everything is loaded but it also didnt help. 

I highly doubt that OnCalculate is being called before OnInit has completed, but if it really is the case, then try using something like the following ...

bool g_bReady = false;

int OnInit( void )
{
   g_bReady = false; // Not ready

   // ... do other tasks ...

   g_bReady = true;  // Ready
   return INIT_SUCCEEDED;
};

int OnCalculate( ... )
{
   if( !g_bReady ) return 0; // Not ready, so do nothing
   
   // ... do other tasks ...

   return rates_total;
};
 
Fernando Carreiro #:

I highly doubt that OnCalculate is being called before OnInit has completed, but if it really is the case, then try using something like the following ...

Appreciate. I will announce the result in an hour.
 
Fernando Carreiro #:

I highly doubt that OnCalculate is being called before OnInit has completed, but if it really is the case, then try using something like the following ...

didnt help.

It returns the same value as index 0(zero) for all indices.

But in strategy tester it is fine.


 
Yashar Seyyedin #: didnt help. It returns the same value as index 0(zero) for all indices.But in strategy tester it is fine.

If it didn't help, then that shows that the OnCalculate is NOT being called before OnInit has completed. I did say that I doubted that it was the case.

Remember that when the market is closed, there are no ticks and OnCalculate is NOT called.

 
Fernando Carreiro #:

If it didn't help, then that shows that the OnCalculate is NOT being called before OnInit has completed. I did say that I doubted that it was the case.

Remember that when the market is closed, there are no ticks and OnCalculate is NOT called.

Agree. So we should look for another potential bug in code.

 
Yashar Seyyedin:

This indicator loads properly when applying the single time frame mode(use alternate resolution=false)


But when applying (use alternate resolution=true) it won't work in closed market. But works properly with strategy tester.

was not solved after all ? 

weird , what does the sub-indicator when it's called for the first time ? 

 
Lorentzos Roussos #:

was not solved after all ? 

weird , what does the sub-indicator when it's called for the first time ? 

some pro guy solved and sent me the ex5 file. and not the source code!

 
Yashar Seyyedin #:

some pro guy solved and sent me the ex5 file. and not the source code!

In freelance ? 

 
Lorentzos Roussos #:

In freelance ? 

Yes.