Errors, bugs, questions - page 2958

 
What are you talking about?
 
Vladimir Karputov:
What do you mean?

Search is not working properly, I wanted to filter your indicators in CodeBase by publication date

https://www.mql5.com/ru/search#!keyword=Vladimir%20Karputov&module=mql5_module_codebase&method=2

https://www.mql5.com/ru/search#!keyword=%D0%B8%D0%BD%D0%B4%D0%B8%D0%BA%D0%B0%D1%82%D0%BE%D1%80&module=mql5_module_codebase&method=2&author=Vladimir%20Karputov

The one closest to the desired one.

 

These two links work. Probably old link format was or site bases were updated.

 
Vladimir Karputov:

These two links work. Maybe it was an old link format or there was an update to the site's databases.

Of course they work, but in my opinion, they don't do what I expect.

I thought I'd see the first one by date https://www.mql5.com/ru/code/33553.

and the second one had some other authors in it.

It's a minor thing, of course.

 

I would like to keep it simple. When a new symbol from Market Watch is drawn on the chart (i.e. when the symbol changes), I need to recognise it and take an action.

#property indicator_chart_window

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }

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[])
  {
   return(rates_total);
  }

void OnDeinit(const int reason)
  {
   string old_symbol=_Symbol;
   string new_symbol;

   Print("The current symbol is ",old_symbol,".");

   if(_UninitReason==REASON_CHARTCHANGE)
   {
      new_symbol=_Symbol;
      Print("Was: ",old_symbol,", now: ",new_symbol,".");
   }

   return;
  }

I put EURUSD on USDCHF, it says:

2021.02.14 17:56:26.700 test (USDCHF,M20)       The current symbol is USDCHF.
2021.02.14 17:56:26.700 test (USDCHF,M20)       Was: USDCHF, now: USDCHF.

At the same time on the chart the pair, of course, changes to EURUSD. When I remove the indicator from the chart it says(that it's too late):

2021.02.14 18:02:54.006 test (EURUSD,M20)       The current symbol is EURUSD.

A is expected immediately:

2021.02.14 18:00:44.660 test (USDCHF,M20)       The current symbol is USDCHF.
2021.02.14 18:00:44.660 test (USDCHF,M20)       Was: USDCHF, now: EURUSD.

What am I doing wrong?

EURUSD - Euro vs US Dollar - Курс валют сегодня — Форекс курсы валют
EURUSD - Euro vs US Dollar - Курс валют сегодня — Форекс курсы валют
  • www.mql5.com
EURUSD - Euro vs US Dollar - Графики с курсом по самым популярным валютным парам. Используйте фильтр снизу, чтобы отбирать нужные вам курсы валют. Внутри каждого графика показываются цены спроса и предложения, а также прирост за день.
 
x572intraday:

I would like to keep it simple. When a new symbol from Market Watch is drawn on the chart (i.e. when the symbol changes), I need to recognise it and take an action.

I put EURUSD on USDCHF, it says:

At the same time on the chart the pair, of course, changes to EURUSD. When I remove the indicator from the chart it says(that it's too late):

A is expected:

What am I doing wrong?

What in

OnDeinit(

Put more in OnInit and everything becomes clear.

 
x572intraday:

I would like to keep it simple. When a new symbol from Market Watch is thrown onto the chart (i.e. when the symbol changes), you need to recognise this and take an action.

In the indicator we need to save the symbol in OnDeinit (for example, in global). In OnInit wait for OnDeinit of the previous indicator and read the saved symbol.
#property indicator_chart_window
#property indicator_plots   0

#include <Init_Sync.mqh> // https://www.mql5.com/ru/code/18138

int OnInit()
{  
  // https://www.mql5.com/ru/forum/189649#comment_4854618
  if (GlobalVariableCheck((string)ChartID()))
  {
    const string PrevSymb = _GlobalVariableGet<string>((string)ChartID());
    
    if (PrevSymb != _Symbol)
      Alert(PrevSymb + " -> " + _Symbol);
    
    _GlobalVariableDel((string)ChartID());  
  }
    
  return(INIT_SUCCEEDED);
}

void OnDeinit( const int Reason )
{
  if (Reason == REASON_CHARTCHANGE)
    _GlobalVariableSet((string)ChartID(), _Symbol + "");
}

void OnChartEvent( const int id,
                   const long& lparam,
                   const double& dparam,
                   const string& sparam )
{
}

void OnTimer()
{
}

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[] )
{
  return(rates_total);
}
This example creates a global one with (string)ChartID()-name. If there is more than one indicator on the chart, the logic should be a little more complex.
 
fxsaber:
In indicator you need to save symbol in OnDeinit (for example, in global). In OnInit wait for the execution of OnDeinit of the previous indicator and read the saved symbol. This example creates a global one with (string)ChartID()-name. If there is more than one indicator on the chart, the logic should be a little more complex.

TypeToBytes.mqh and crc64.mqh compiled successfully, but Init_Sync.mqh produced a bunch of errors. That is, the matter didn't even get to the compilation of the example. And I'm thinking with terror that such trivial task requires several stubby libraries some of which don't want to compile either. I've just never plugged anything external before, except my own custom indicator.

 
x572intraday:

TypeToBytes.mqh and crc64.mqh compiled successfully, but Init_Sync.mqh produced a mountain of errors when compiling.

It's compiling now.

 
fxsaber:

It's compiling for me.

Uh-huh, that's how it worked.

Reason: