FORTS Please help - page 5

 

Someone is lying, or Michael is not accepting the tech support objections, or tech support does not want to acknowledge the problem.

Mikalas 2015.03.26 00:44  RU

Again servicedexk can't reproduce the error!


alexvd2015.03.26 15:16

Wrong code in the first post too.

 
MigVRN:

Let's be friends :)

But not immediately - but when the load is successful.

Your code shows that the OnInit function is useless, or developers screwed up.

 
Mikalas:

Yeah, well, what if there really is no data?

What then? A cycle? With how many iterations?

There are no specific recipes here...

I don't like indicators at all... That's the only reason:

In the same thread with indicators, the other operations are executed sequentially for that symbol - the processing of ticks and history synchronization. It means that if an endless action is executed in an indicator, all the other events for that symbol will never be executed.

They can make chat, and everything else, slow down. Therefore, I use them without requests for quotes from neighboring chats and as a provider of custom events. In general, work only with what came in OnCalculate().

Serj_Che:

In your code you see that the OnInit function is useless, or developers screwed around.

This is your code - I have only pasted into it whatalexvd said. I have not understood why it means thatthe OnInit function is useless.

 
alexvd:
In your code, you just have to clear the error in the global variable is_failed right after ResetLastError(). Otherwise once you have caught an error you will get a message about it

Bingo! You're almost there.) There's a reason they say trust but verify. The final text is below.

#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//
bool is_failed = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
  SymbolSelect( "MIX-6.15", true );
  SymbolSelect( "RTS-6.15", true );
  SymbolSelect( "Si-6.15", true );
//---  
  ResetLastError();
//---  
  int total_bars = Bars( "MIX-6.15", PERIOD_M1 );
  if ( total_bars > 0 )
  {
    total_bars = Bars( "RTS-6.15", PERIOD_M1 );
    if ( total_bars > 0 )
    {
      total_bars = Bars( "Si-6.15", PERIOD_M1 );
      {
        if ( total_bars > 0 )
        {
           is_failed = false;
           Print( "Init OK." );
        }
        else
        {
          is_failed = true;
          Print( "Get Bars failed Si-6.15 Last error = ", string(GetLastError() ) );
        }
      }
    }
    else
    {
      is_failed = true;
      Print( "Get Bars failed RTS-6.15 Last error = ", string(GetLastError() ) );
    }
  }
  else
  {
    is_failed = true;
    Print( "Get Bars failed MIX-6.15 Last error = ", string(GetLastError() ) );
  } 
//---
   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[])
  {
  ResetLastError();
//---  
 int total_bars = Bars( "MIX-6.15", PERIOD_M1 );
  if ( total_bars > 0 )
  {
    total_bars = Bars( "RTS-6.15", PERIOD_M1 );
    if ( total_bars > 0 )
    {
      total_bars = Bars( "Si-6.15", PERIOD_M1 );
      {
        if ( total_bars > 0 )
        {
          Print( "Init OK." );
          is_failed = false;
        }
        else
        {
          is_failed = true;
          Print( "Get Bars failed Si-6.15 Last error = ", string(GetLastError() ) );
        }
      }
    }
    else
    {
      is_failed = true;
      Print( "Get Bars failed RTS-6.15 Last error = ", string(GetLastError() ) );
    }
  }
  else
  {
    is_failed = true;
    Print( "Get Bars failed MIX-6.15 Last error = ", string(GetLastError() ) );
  } 
//---
   if ( is_failed )
   {
     Print( "Sorry! Get Bars failed." );
   }
   else Print( "Bingo! We done.");
//--- return value of prev_calculated for next call
   return(rates_total);
  }
 
MigVRN:

There are no specific recipes here...

I don't like indicators at all... That's the only reason:

In the same thread with indicators other actions concerning the symbol are performed sequentially - the processing of ticks and history synchronization. It means that if an infinite action is executed in the indicator, all other events for this symbol will never be executed.

They can make the chat, and everything else, slow down. Therefore, I use them without requests for quotes from neighbouring chats and as a provider of custom events. In general, only work with what came in OnCalculate().

This is your code - I've only put in whatalexvd mentioned. I don't understand why it follows thatthe OnInit function is useless.

What code is that mine? I have not posted any code here.

The indicators will not slow down everything else. The point is that everything is out of sync in MT5, indicators work in their threads and EAs in theirs. The glass is on its own.

I don't like indicators either, but I have to use them from time to time.

 
Dima_S:

Bingo! You're almost there.) They say trust but verify for a reason. The final text is below.

Why do you repeat in OnCalculate what was in OnInit? Is it such a spell?)
 
Serj_Che:

What is my code? I haven't posted any codes here.

OH... Sorry. I got confused with Dima_S.

Serj_Che:

I will not slow down everything else because of the indicators. The thing is that everything is out of sync in MT5, indicators work in their thread and EAs in theirs. The glass is on its own.

I don't like indicators either, but I have to use them from time to time.

The indicators work in their threads... But the chat works in this flow. If something goes wrong in an indicator (an eternal loop inOnCalculate()) the Expert Advisor that works in its "own" flow - won't see anything from the chat...

 
MigVRN:

OOO... sorry. confused with Dima_S.

The indicators are running in their thread... Only the chat works in the same thread. And if something goes wrong in an indicator (an eternal loop inOnCalculate()) the Expert Advisor that runs in "its" thread will not see anything from that chat...

I doubt, I'm even more inclined to think that it's not so, the Expert Advisor should work by itself. I haven't had any such troubles, but if you want, you can check this extreme.

 
Serj_Che:

I doubt it, I'm even more inclined to think it's not, the EA should work on its own. There have been no such fiddles specifically, but you can check such extremes if you want to.

I will outline the check code. I will check it in 2-3 hours. But the fact that if the 1 indicator on the chat "slows down" then others slow down with it - it is a fact with which I have repeatedly experienced.
 
MigVRN:
I'll sketch out some test code. In about 2-3 hours. But if 1 indicator on the chat "slows down" then the others slow down with it - it is a fact that I have faced with more than once.

OK, interesting!

Indicators work in their own thread, EAs in their own thread. Unless, of course, it's a single core stone.

Reason: