[SERVICE DESK] Error in getting the time of the senior TF in the timer! - page 13

 
Alexey Kozitsyn:

Read point 1.

To get the opening time of the bar the timer is of no use at all, and any other data, if not from another symbol different from the chart. If it is not related to a symbol different from the current chart, but to another TF of the current symbol, it is interesting. It will not update until the new data arrive. But all your work is based on the current symbol. So do not bother with the timer. The rest as such is chewed over several times. The topic went in a circle.

 
Konstantin Nikitin:

To get the opening time of the bar the timer is of no use at all, and any other data, if not from another symbol different from the chart. If it is not related to a symbol different from the current chart, but to another TF of the current symbol, it is interesting to check it every millisecond. It will not update until the new data arrive. But all your work is based on the current symbol. So do not bother with the timer. The rest as such is chewed over several times. The topic has gone in a circle.

Mate, you obviously don't understand what's going on here. It's not about the timer anymore, forget it. The timer refers to my real problem. The problem now is the error in the data being received. Point 1, which I advised you to read, says that in the presence of IsConnected(), the indicator will connect to the server only on the second event OnCalculate(). So your previous advice is useless.

 
Alexey Kozitsyn:

Mate, you clearly don't understand what's going on here. It's not about the timer anymore, forget it. The timer refers to my real problem. The problem now is the error in the data being received. Point 1, which I advised you to read, says that in the presence of IsConnected(), the indicator will connect to the server only on the second event OnCalculate(). So your previous advice is useless.

Have you checked it experimentally? I advise to check it. So restart the terminal with the test.

int OnCalculate(
   const int rates_total,
   const int prev_calculated,
   const datetime &time[],
   const double &open[],
   const double &high[],
   const double &low[],
   const double &close[],
   const long &tick_volume[],
   const long &volume[],
   const int &spread[]
)
{
   static int num = 1;
   
     
     if( IsConnected() )
          if( num == 1 )
               Comment( "Test: ", num );
     num++;
     return(rates_total);
}

And what do you see?

On the first pass, if there is a connection to the server, everything works.

 
Konstantin Nikitin:

Have you tested it empirically? I suggest you do. So restart the terminal with the test.

And what do you see?

On the first pass, if there is a connection to the server, everything works.

Who in their right mind and mind tests when the market is not working?

And yes, I have tested it empirically, which is what I wrote about.

 
Alexey Kozitsyn:

Who in their right mind and mind tests when the market is not working?

And yes, I tested it experimentally, which is what I wrote about.

This has nothing to do with whether the market is working or not. The indicator has run and its analysis has begun. The result of the first pass is in the commentary. You said

Alexey Kozitsyn:

You should read it - it's about the fact that if IsConnected() is present, the indicator will connect to the server only on the second event OnCalculate(). So your previous advice is useless.

 
Konstantin Nikitin:

What does it have to do with whether the market is working or not? The indicator has started, the analysis is going on. The result of the first pass is in the commentary. You said.

Yeah. All right. Now turn off the terminal with this indicator installed on the chart and run it again.

 
Alexey Kozitsyn:

Yikes. All right then. Now turn off the terminal with this indicator of yours installed on the chart and start it up again.

So this chart

was made just a few minutes before it was first published. That is, today. And it was after restarting the terminal.
The connection with the server is established at the weekend as well. The same balance to check, can get the latest data, if it was disconnected before the session was closed.

 
Konstantin Nikitin:

So this graphic

and it was made just a few minutes before it was first published. That is, today. And it was after the terminal was restarted.
The connection to the server is established at the weekend as well. The same balance to check, can get the latest data, if it was disconnected before the session was closed.

#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   if( !IsConnected() )
     {
        Print( __FUNCTION__,": IsConnected = false" );
        return( 0 );
     }
   //---
   Print( "Connected!" );
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

I'm getting a result:

2018.10.06 18:24:32.261 test_isConnected GBPUSD,M1: initialized
2018.10.06 18:24:32.313 test_isConnected GBPUSD,M1: OnCalculate: IsConnected = false
2018.10.06 18:24:33.080 test_isConnected GBPUSD,M1: Connected!
And your code does not show any comments when loading.
 
Alexey Kozitsyn:

I get a result:

And your code doesn't show any comments when loaded.

Well, it's possible. My server sometimes goes down for maintenance on Sunday, but not for long. It may be one of the reasons for no connection.
It may be another reason why terminal can't connect to server before indicator starts.
My terminal connects immediately.

 
Konstantin Nikitin:

It may very well be. My server may be down for maintenance on Sunday but it won't stay down for long. It may be one of the reasons for the lack of connection.
It may be another reason why terminal has no time to connect to server before start of indicator.
My terminal connects immediately.

Then make it simple: load my indicator with your edits on the chart now. Turn off the terminal. Turn it back on on Monday and see the result. Further discussion is useless.