Errors, bugs, questions - page 1697

 
Karputov Vladimir:
Print(MQLInfoString(MQL_PROGRAM_NAME)); returns short indicator name. If no short name is specified, the full name will be returned.
Thank you.
 
Vladimir Pastushak:

Thank you.

Alexey, your example doesn't work, the parent's methods are still dumped in the inheritor, which shouldn't be dumped.


It shouldn't be like this, can you throw the code?

Those data that were protected and publicin the parent will be protected at protected-inheritance.

	          
 
  1. We set the indicator on a NONE chart
    #property indicator_separate_window
    #property indicator_buffers 1
    #property indicator_plots   1
    
    double Buffer[];
    
    int handle = INVALID_HANDLE;
    
    void OnInit()
    {
      ::SetIndexBuffer(0, Buffer, INDICATOR_DATA);
      
      handle = ChartIndicatorGet(0, 1, ChartIndicatorName(0, 1, 0));  
    }
    
    #define  TOSTRING(A) #A + " = " + (string)A + "\n"
    
    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 (handle != INVALID_HANDLE)
      {
        Buffer[rates_total - 1] = MathRand();
        
        double BufferCopy[];
        
        if (CopyBuffer(handle, 0, 0, 1, BufferCopy) > 0)
          Print(TOSTRING(BufferCopy[0]) + TOSTRING(Buffer[rates_total - 1]));
      }
      
      return(rates_total);
    }
  2. Remove the indicator from the chart by hand.
  3. In the log we see that the indicator continues to run. You can close all the charts in the terminal, but it will still be executing. And it won't help, of course,
    void OnDeinit( const int Reason )
    {
      if (handle != INVALID_HANDLE)  
        IndicatorRelease(handle);
      
      return;
    }
  4. Rebooting the terminal stops the execution of the indicator.
  5. How many indicators can be idle and we don't even know about them? There is no control at all.
 
fxsaber:
  1. Hand-setting the NULL indicator on the chart
  2. Remove the indicator from the chart by hand.
  3. In the log we see that the indicator continues to run. You can close all the charts in the terminal, but it will still be executed.
  4. Rebooting of the terminal stops the execution of the indicator.
  5. How many indicators can be idle and we haven't even heard anything about them? There is no control at all.

It is impossible to read and look through codes with#define and with ::

Please rewrite the codes in the style of common MQL5.

 
fxsaber:
  1. Hand-setting the NULL indicator on the chart
  2. Remove the indicator from the chart by hand.
  3. In the log we see that the indicator continues to run. You can close all the charts in the terminal, but it will still be executed.
  4. Rebooting of the terminal stops the execution of the indicator.
  5. How many indicators can be executed in idle mode and we have not even heard of them? There is no control at all.
Adding the _StopFlag check will not help?
 
Karputov Vladimir:

It is impossible to read and watch the codes with#define and with ::

Please rewrite the codes in common MQL5 style.

This is the MQL5 style. Please study what is #define and what is ::.
 
Alexey Kozitsyn:
Adding a _StopFlag check won't help?
Where to add it and how can it at least theoretically help. This is a bug of the terminal. And it is a serious bug. I was lucky - I see in the log that the indicator works. However, there are a lot of indicators that work in the terminal without any information about them. But the topic comes up, and why is my CPU so loaded on an empty terminal?
 
fxsaber:
This is the style of MQL5. Please study what is #define and what is ::.
That's not what I mean. The "::" is not needed at all in your examples - maybe it's your habit, but it's not needed there at all. The code can be written normally without #defane as well. Just try to rewrite it and see if something becomes clear.
 
Karputov Vladimir:
That's not what I mean. "::" is not needed at all in your examples - maybe it is your habit, but it is not needed there at all. The code can be written just fine without #defane. Just try to rewrite it and see if something becomes clear.

I only had "::" in one place. And I don't write codes from scratch. As a rule, I take something out of my codes. Here's ::: there was one through copy-paste. I'd never paid attention to it but I've removed it since it makes you feel so much better.

But it's not a matter of principle not to remove #define. 99% of the code can be written without it. This is not an occasion to take it away.

And there is 1% (relatively) when you cannot do without #define!

 
fxsaber:

I only had "::" in one place. And I don't write codes from scratch. As a rule, I take something out of my codes. Here's ::: there was one through copy-paste. I'd never paid attention to it but I've removed it since it makes you feel so much better.

But it's not a matter of principle not to remove #define. 99% of the code can be written without it. This is not an occasion to take it away.

And there is 1% (conditionally) when you cannot do without #define!

If you don't copy the buffer:

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1

double Buffer[];

int handle=INVALID_HANDLE;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnInit()
  {
   SetIndexBuffer(0,Buffer,INDICATOR_DATA);

   handle=ChartIndicatorGet(0,1,ChartIndicatorName(0,1,0));
  }

#define  TOSTRING(A) #A + " = " + (string)A + "\n"
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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(handle!=INVALID_HANDLE)
     {
      Buffer[rates_total-1]=MathRand();

      double BufferCopy[];
      Print(__FUNCTION__);
      //if(CopyBuffer(handle,0,0,1,BufferCopy)>0)
      //   Print(TOSTRING(BufferCopy[0])+TOSTRING(Buffer[rates_total-1]));
     }

   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int Reason)
  {
   Print("#1 OnDeinit");
   if(handle!=INVALID_HANDLE)
     {
      Print("#2 OnDeinit");
      IndicatorRelease(handle);
      Print("#3 OnDeinit");
     }
   Print("#4 OnDeinit");
   return;
  }
//+------------------------------------------------------------------+

then the indicator successfully completes its work

2016.09.23 12:11:12.655 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:12.737 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:12.737 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:12.737 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:12.747 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:13.406 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:13.406 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:13.406 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:14.794 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:15.747 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:16.936 2 (SBRF-12.16,M1)       OnCalculate
2016.09.23 12:11:19.339 2 (SBRF-12.16,M1)       #1 OnDeinit
2016.09.23 12:11:19.339 2 (SBRF-12.16,M1)       #2 OnDeinit
2016.09.23 12:11:19.339 2 (SBRF-12.16,M1)       #3 OnDeinit
2016.09.23 12:11:19.339 2 (SBRF-12.16,M1)       #4 OnDeinit
Reason: