Questions from Beginners MQL5 MT5 MetaTrader 5 - page 947

 
Good afternoon, please advise... After upgrading to the latest build, errors in "SmoothAlgorithms" started to fly out. And sma, lwma, parma, vidya averaging stopped working. It is swearing at this line: "array out of range in 'SmoothAlgorithms.mqh' (3394,9)". How should I fix it? Thank you!
Files:
 
007yurik:
Good afternoon, please advise... After upgrading to the latest build, errors in "SmoothAlgorithms" started to pop up. And sma, lwma, parma, vidya averaging stopped working. It is swearing at this line: "array out of range in 'SmoothAlgorithms.mqh' (3394,9)". How should I fix it? Thank you!
Write to the author on the discussion page of his library:
Библиотеки: SmoothAlgorithms
Библиотеки: SmoothAlgorithms
  • 2017.01.31
  • www.mql5.com
SmoothAlgorithms: Автор: Nikolay Kositsin...
 
Artyom Trishkin:
Write about it to the author on the discussion page of his library:
Thanks, but he didn't reply. In another thread, I'll try the one on offer.
 

There is a need to use numeric values as enumeration elements.

enum ENUM_HOURS
{
 0,
 1,
 ..,
 23
};

This is not allowed. Compilation error identifier expected. Is there any way around it (leaving only numeric values)?

 
Juer:

There is a need to use numeric values as enumeration elements.

This is not allowed. Compilation error identifier expected. Is there any way around it (leaving only numeric values)?

//+------------------------------------------------------------------+
enum ENUM_HOURS
  {
   HOUR_0,  // 0
   HOUR_1,  // 1
   HOUR_2,  // 2
   HOUR_3,  // 3
   HOUR_4,  // 4
   HOUR_5,  // 5
   HOUR_6,  // 6
   HOUR_7,  // 7
   HOUR_8,  // 8
   HOUR_9,  // 9
   HOUR_10, // 10
   HOUR_11, // 11
   HOUR_12, // 12
   HOUR_13, // 13
   HOUR_14, // 14
   HOUR_15, // 15
   HOUR_16, // 16
   HOUR_17, // 17
   HOUR_18, // 18
   HOUR_19, // 19
   HOUR_20, // 20
   HOUR_21, // 21
   HOUR_22, // 22
   HOUR_23  // 23
  };
//+------------------------------------------------------------------+
 

Can you give me a link to the documentation of what these <> symbols mean?

_GlobalVariableGet<string>("ResourceName")
 

Is there any way to programmatically set a list of parameters to be optimised?

The thing is that I have a lot of parameters. Thousands of them. I put them in a separate program. EA loading them during initialization through external file. So my task is to optimize these parameters now.

That is for example a list of optimizable parameters with values and ranges in a file. Read from there and write the result there as well.

 

I am writing a function to close charts with no EAs or scripts. I get the name of Expert Advisor and script on the chart using ChartGetString function. If both are empty, I close them. The problem is in the line with chart closing according to the condition. The condition is never satisfied. Here is the code.

 if( ExpertName == "" && ScriptName == "" ){ChartClose ( prevChart );}
 else Print("Не закрываем график . Имя эксперта =",ExpertName,"= ScriptName =",ScriptName,"=");

Here is what Print shows

Не закрываем график . Имя эксперта == ScriptName ==

I understand that we can change the condition to the following

StringLen(ExpertName) == 0 && StringLen(ScriptName) == 0

Well, how else should we compare the string variable with an empty string?

 

Good afternoon! I have made .mqh for data processing and storage in the resource. Everything works, but there is a nuance, if I compile the indicator, the .mqh is reset and re-does the weight process for storage. Target - as long as there is data in the resource it is not reset. Where is the error, how to fix it?

// Сохранение данных
#include <fxsaber\TradeTransactions\ResourceData.mqh> // https://www.mql5.com/ru/code/22166
#include <GlobalVariables.mqh> 

const RESOURCEDATA<MqlTick>m_Resource("::"+__FILE__); // Ресурс для передали данных (тики)
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class CMyTicks
  {
protected:
public:
   //+------------------------------------------------------------------+
   //| Constructor.                                                     |
   //+------------------------------------------------------------------+      
   void CMyTicks()
     {
      _GlobalVariableSet("ResourceName",m_Resource.GetFullName()); // Записали в глобальную переменную полное имя ресурса (read-only)      
     }
   //+------------------------------------------------------------------+
   //| Destructor.                                                     |
   //+------------------------------------------------------------------+      
   void ~CMyTicks()
     {
      //_GlobalVariableDel("ResourceName");
     }

   //+------------------------------------------------------------------+  
   void CollectTicks()
     {
      MqlTick m_Ticks[];
      CopyTicks(_Symbol,m_Ticks,COPY_TICKS_ALL,0,5); // Сформировали данные
      m_Resource=m_Ticks; // Записали данные
     }
  };
//+------------------------------------------------------------------+
// Получение данных
#property indicator_chart_window
#property indicator_plots 0

#include <Test_Keep_Info_13.mqh>
CMyTicks  Test;

#include <fxsaber\TradeTransactions\ResourceData.mqh> // https://www.mql5.com/ru/code/22166
#include <GlobalVariables.mqh> 

static const RESOURCEDATA<MqlTick>Resource(_GlobalVariableGet<string>("ResourceName")); // Создали ресурс на основе переданного в глобальной переменной полного имени  
MqlTick Ticks[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,const int,const double &[])
  {
   if(prev_calculated==0)
     {
      Resource.Get(Ticks); // Считали данные из ресурса.
      ArrayPrint(Ticks);   // Распечатали полученные данные

      if(ArraySize(Ticks)<1)
        {
         Test.CollectTicks();
         Print(" SAVE TICKS ");
        }

      Resource.Get(Ticks); // Считали данные из ресурса.
      ArrayPrint(Ticks);   // Распечатали полученные данные
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
pivomoe:

How do I correctly compare a variable string with an empty string ?

There are two normal empty strings - "" and NULL. And there can also be custom empty strings.

Reason: