Errors, bugs, questions - page 2971

 

Is this the correct behaviour for the static variables?

When switching timeframes or changing parameters, their value does not change:

int OnInit()
  {
   static int my_int=4444;
   Print(my_int);
   my_int=9999;
   return(INIT_SUCCEEDED);
  }

The result after starting the EA and switching the timeframe:

2021.02.24 16:23:27.999 Test1 (EURUSD,M1)       4444
2021.02.24 16:23:29.913 Test1 (EURUSD,M5)       9999
Static variables

This is from the help:

Static variables exist at the moment of program execution and are initialized once before call of the specialized function OnInit().

So once before each call to OnInit() or once before startup, although re-initialisation is more like a second run.

Does this also happen in the tester?

Global variables behave this way too.

 

When switching timeframes, the Expert Advisor does not restart, it continues to work

https://www.mql5.com/ru/docs/runtime/running

При смене символа или таймфрейма графика, к которому эксперт прикреплен, выгрузка и загрузка эксперта не производится. При этом последовательно вызываются обработчики OnDeinit() на старом символе/таймфрейме и OnInit() на новом символе/таймфрейме (если они есть), значения глобальных переменных и статических переменных не сбрасываются. Все события, поступившие для эксперта до завершения инициализации (функции OnInit()), пропускаются.


Документация по MQL5: Программы MQL5 / Выполнение программ
Документация по MQL5: Программы MQL5 / Выполнение программ
  • www.mql5.com
Выполнение программ - Программы MQL5 - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Ilyas:

When switching timeframes, the Expert Advisor does not restart, it continues to work

https://www.mql5.com/ru/docs/runtime/running

I have noticed one peculiarity that was not present in MetaTrader before. When I delete an Expert Advisor from a chart (using its context menu command), the chart closes after it. Previously, the chart did not close after deleting an Expert Advisor.

 
Mihail Matkovskij:

I noticed one peculiarity that was not present in MetaTrader before. When I delete an Expert Advisor from a chart (using its context menu command), the chart closes after it. Previously, the chart was not closed after deleting an Expert Advisor.

It can be programmed in the EA itself, check with another EA...

 

in win7 when debugging on historical data variables added to the observation do not display their values. when debugging on real data everything works.i have specified parameters for debugging in the meta-editor settings.

it turns out, that when adding variables, they are not displayed in the window immediately, but appear only when debugging is started next time, but their values are already <not implemented>. please tell me what to set to make debugging work

 
Vladimir Pastushak:

It may be programmed in the EA itself, check with another EA...

Indeed, threw the standard EA on the chart. Deleted it without any problems. Tried to find ChartClose in sources of my Expert Advisor. I have not found it anywhere. It was not my intention from the beginning to close the chart when deleting an Expert Advisor. I use standard UI elements, such as CAppDialog. Maybe, the closing of chart was written somewhere in standard classes...

 
Mihail Matkovskij:

Indeed, threw a standard EA on the chart. Deleted it without any problems. Tried to find ChartClose in sources of my Expert Advisor. I have not found it anywhere. My initial idea was not to close the chart when deleting an Expert Advisor. I use standard UI elements, such as CAppDialog. Maybe, the closing of the chart was written somewhere in standard classes...

Found it. The CAppDialog class has a CChart m_chart field.

class CAppDialog : public CDialog
  {
...
protected:
   CChart            m_chart;               // object to access chart

WhenCAppDialog is deleted (its descendant is used in my Expert Advisor),the m_chart destructor will probably close the chart.

//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
CChart::~CChart(void)
  {
   if(m_chart_id!=-1)
      Close();
  }
//+------------------------------------------------------------------+
//| Chart close                                                      |
//+------------------------------------------------------------------+
void CChart::Close(void)
  {
   if(m_chart_id!=-1)
     {
      ChartClose(m_chart_id);
      m_chart_id=-1;
     }
  }

Unfortunately, this process cannot be tracked using the debugger. But after looking through the source codeof CAppDialog, as well asCChart, everything becomes clear. I draw developers' attention to this.

 
Mihail Matkovskij:

Found it. The CAppDialog class has CChart m_chart field.

WhenCAppDialog is removed (its descendant,CDialog, is used in my Expert Advisor),the m_chart destructor probably closes the chart.

Unfortunately, this process cannot be tracked using the debugger. But after looking through the source codeof CAppDialog, as well asCChart, everything becomes clear. I would like to draw the developers' attention to this.

void CAppDialog::Destroy(const int reason)

Detaching from the chart, among other things.

 

Can you tell me why SignalBaseTotal() always returns 1000.

The mql5.com signals service has more than a thousand broadcasted signals, but the terminal has only a thousand available. Why?

Can it be that there is one set of signals in this thousand, while it can be different in an hour?
Документация по MQL5: Управление сигналами / SignalBaseTotal
Документация по MQL5: Управление сигналами / SignalBaseTotal
  • www.mql5.com
SignalBaseTotal - Управление сигналами - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alain Verleyen :

Error with derived structure where no new data is added when saving/loading from file.

@Ilyas Will you fix this?