Discussion of article "Use of Resources in MQL5"

 

New article Use of Resources in MQL5 is published:

MQL5 programs not only automate routine calculations, but also can create a full-featured graphical environment. The functions for creating truly interactive controls are now virtually the same rich, as those in classical programming languages. If you want to write a full-fledged stand-alone program in MQL5, use resources in them. Programs with resources are easier to maintain and distribute.

Author: MetaQuotes

 

Now it is even easier to include resources in your MQL5 programmes, a special standard command "Insert resource" has been added in MetaEditor 5 for this purpose:



Вставка ресурсов

To facilitate the use of resource files in developed applications, the "Insert resources Insert Resources" command is provided in the "Service " menu. This command allows you to insert the declaration of resource files selected from a specified folder into the current file using the #resource directive.

After executing this command, a standard operating system dialogue box appears in which you must select one or more resource files to be declared in the file.

  • Resource files can be located only inside the /MQL5 directory of the client terminal. Files outside this folder cannot be used.
  • Only *.wav and *.bmp files can be used as resource files.

After that, the corresponding directives of the following form will be added to the beginning of the current file:

#resource "\Images\example.bmp"
or
#resource "resources\example.bmp"

The path to resource files can be specified in two ways:

  • Relative to the current file (without the "\" symbol at the beginning of the path)
    This method is used if the resource files are located in the same folder as the current file or in one of its subfolders.
  • Regarding the /MQL5 directory of the client terminal (with the "\" symbol at the beginning of the path)
    This method is used in all other cases.
 

Now including resources into your MQL5 programs became even easier. To do this, MetaEditor 5 has the special Insert Resources command.


Resources Inserting

To make using of resource files in developed applications easier, the "Insert Resources Insert Resources" command is implemented in the "Tools" menu. This command allows declaring resource files from a selected folder in the current file using the #resource directive.

Once this command is executed, the standard dialog window of your operating system appears. In it you should select one or several resource files to be declared in the file.

  • Resource files can be located only within the /MQL5 directory of the client terminal. Files outside that directory cannot be used.
  • Only *.wav and *.bmp files can be used as resource files.

Once the above actions are performed, the corresponding directives will be added to the beginning of the file. For example:

#resource "\Images\example.bmp"
or
#resource "resources\example.bmp"

The path to resource files can be specified in two ways:

  • Relatively to the current file (without the "\" symbol at the beginning of path)
    This way is used in case the resource files are located in the same directory as the current file or in one of its subfolders.
  • Relatively to the /MQL5 directory of the client terminal (the "\" symbol is specified at the beginning of path)
    This way is used in all other cases.
 

MetaTrader 5 Client Terminal build 730
MQL5: Added support for storing indicators in EX5 resources. 

#resource "Examples\Fractals.ex5"

Could someone please give an example of how to use the indicator.

 
When will it be possible to insert indicator files called in the main file via iCustom() as a resource? There is so much rubbish in the terminal folders that it is not even clear what belongs to what. It is not safe. I would like to learn how to collect one project into one ex5 file.
 
MoneyJinn:
When will it be possible to insert indicator files called in the main file via iCustom() as a resource? There is so much rubbish in the terminal folders that it is not even clear what belongs to what. It is not safe. I would like to learn how to collect one project into one ex5 file.

This was added in the 730 build on 24 November 2012:

  • MQL5: Added support for storing indicators in EX5 resources. Indicators in resources will not be able to work with their own resources.


Here is a simple example. First compile the standard CHO indicator in the specified path, then this Expert Advisor, and then drop it on the chart.

#resource "\\Indicators\\Examples\\CHO.EX5"
//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   int handle=iCustom(Symbol(),Period(),"::Indicators\\Examples\\CHO.EX5");
   if(handle!=INVALID_HANDLE)
     {
      Print("Indicator created!");
      IndicatorRelease(handle);
     }
//---
   return(0);
  }
void OnDeinit(const int reason)
  {
  }
void OnTick()
  {
  }

Pay attention to the correct choice of paths, area modifier :: and correct use of slashes.

We specifically made it possible to package indicators into resources so that you can make self-sufficient and complete products.

 
Renat:

This was added in build 730 back on 24 November 2012:

  • MQL5: Added support for storing indicators in EX5 resources. Indicators in resources will not be able to work with their own resources.

...

How did I miss this moment? I'm waiting for this feature, but it has been there for a long time. Thank you. ))
 
Renat:

Thank you. That's just what I need.

 
is it possible to include resources in ex4 (mt4) products?  Or is this 'resources' thing exclusively an ex5 (mt5) feature?
 
FinGeR:

Could someone please give an example of how to use the indicator.

Example: https://www.mql5.com/ru/forum/3409#comment_408123

#resource "\\Indicators\\Examples\\CHO.EX5"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   int handle=iCustom(Symbol(),Period(),"::Indicators\\Examples\\CHO.EX5");
   if(handle!=INVALID_HANDLE)
     {
      Print("Indicator created!");
      IndicatorRelease(handle);
     }
//---
   return(0);
  }
void OnDeinit(const int reason)
  {
  }
void OnTick()
  {
  }
Обсуждение статьи "Использование ресурсов в MQL5"
  • www.mql5.com
Программы на MQL5 позволяют не только автоматизировать рутинные вычисления, но и создавать полноценную графическую оболочку.
 
4evermaat:
is it possible to include resources in ex4 (mt4) products?  Or is this 'resources' thing exclusively an ex5 (mt5) feature?
Only for MQL5.
This website uses cookies. Learn more about our Cookies Policy.