Libraries: Expert - page 10

 

What is not intuitive is that arrays of parameters and names return different sizes, because there is no null parameter in names, which represents the name of the Expert Advisor.

Also I would like to know the real types of parameters, now "string" is returned everywhere. I don't know how to provide this - the head-on way: analyse the contents of the string and its reducibility to a floating-point number or integer, but if the parameter stores "0", its type cannot be identified.

 
Stanislav Korotky:

What is non-intuitive is that the parameter and name arrays return different sizes because the names lack a null parameter representing the name of the Expert Advisor.

Yes, it is not very nice. Perhaps we should have made a fake null element for Names[].

Also I would like to know the real types of parameters, right now "string" is returned everywhere. I don't know how to provide this - the way to do it head-on: analyse the contents of the string and its reducibility to a floating point number or integer, but if the parameter stores "0", you can't identify its type.

I considered it unnecessary in the library, because there are still custom ENUMs. Moreover, I didn't see a task where it might be necessary.

I was making my own auto-optimiser. It was not useful there.

 
fxsaber:

Yes, it's not very nice. Perhaps you should have made a fake null element for Names[].

I considered it unnecessary in the library, because there are also custom ENUMs. Moreover, I didn't see a task where it could be necessary.

I was making my own auto-optimiser. It was not useful there.

ParameterGetRange/ParameterSetRange functions are defined only for long and double types, so the parameter loop requires to analyse and change settings only for numbers.

 
Stanislav Korotky:

ParameterGetRange/ParameterSetRange functions are defined only for long and double types, respectively, the loop on parameters requires to analyse and change settings only for numbers.

Integer types are bool, enums.

 
fxsaber:

Integer types are bool, enums.

This is normal. It is not normal that now everything is represented by strings and it is impossible to sift out real strings.

 
Stanislav Korotky:

That's normal. What's not normal is that everything is now represented by strings and you can't sift out the actual strings.

The parameters to be optimised are numbers in advance. So there are definitely no strings among them. So you can use it as a filter.

 

Hi, I can't figure out how to open on expert with authorised trade

this code opens normally with the inputs I pass.

   Params[0].string_value = "Experts\\Shared Projects\\luipaulo89\\experts\\PullbackEA_v2.ex5";
// The first input parameter of the Expert Advisor
   Params[1].type = TYPE_STRING;
   Params[1].string_value = "Hello World!";
   Params[2].type = TYPE_INT;
   Params[2].integer_value = 0;
// On a new chart, run the Expert Advisor
   if (inpFirst==1) EXPERT::Run(ChartOpen(_Symbol, _Period), Params);

If I use this code

   Params[0].string_value = "Experts\\Shared Projects\\luipaulo89\\experts\\PullbackEA_v2.ex5";
   Params[0].string_value += "\nexpertmode=5";
// The first input parameter of the Expert Advisor
   Params[1].type = TYPE_STRING;
   Params[1].string_value = "Hello World!";
   Params[2].type = TYPE_INT;
   Params[2].integer_value = 0;
// On a new chart, run the Expert Advisor
   if (inpFirst==1) EXPERT::Run(ChartOpen(_Symbol, _Period), Params);

it opens with allowed trade but does not pass parameters.

The task is to open the same Expert Advisor on a new chart.

input group "EA Settings"
input int inpFirst = 1;//first instance;

so that only the first Expert Advisor can open new ones, I pass 0 to new ones, but unfortunately in the second variant (when trading is allowed) no parameters are passed (or passed incorrectly).

inpFirst = 0;
 

in the tpl file the header is created perfectly, but for some reason it does not pass the parameter

<expert>
name=PullbackEA_v2
path=Experts\Shared Projects\luipaulo89\experts\PullbackEA_v2.ex5
expertmode=5
<inputs>
inpFirst=1

expected to be inpFirst=0

   Params[1].type = TYPE_INT;
   Params[1].integer_value = 0;
 
Aleksei Beliakov:

Update the library.

Test Expert Advisor.

input group "EA Settings"
input int inpFirst = 1;//first instance;

void OnInit() {}


Example1.

#include <fxsaber\Expert.mqh>

void OnStart()
{
  MqlParam Params[3];

  // Pathway to Counsellor
  Params[0].string_value = "Experts\\Test6.ex5";
  Params[0].string_value += "\nexpertmode=5";

  // input group "EA Settings"
  Params[1].type = TYPE_STRING;
  Params[1].string_value = NULL;

  // input int inpFirst
  Params[2].type = TYPE_INT;
  Params[2].integer_value = 123;

  EXPERT::Run(ChartOpen(_Symbol, PERIOD_CURRENT), Params); // Will not be able to correctly run the Expert Advisor on its own chart
}


Example2.

#include <fxsaber\Expert.mqh>

void OnStart()
{
  MqlParam Params[3];

  // Pathway to Counsellor
  Params[0].string_value = "Experts\\Test6.ex5";
  Params[0].string_value += "\nexpertmode=5";
  
  // input group "EA Settings"
  Params[1].type = TYPE_STRING;
  Params[1].string_value = NULL;
  EXPERT::AddInputName(Params[1], " "); // Probl.

  // input int inpFirst
  Params[2].type = TYPE_INT;
  Params[2].integer_value = 123;
  EXPERT::AddInputName(Params[2], "inpFirst");

  EXPERT::Run(0, Params); // Will be able to correctly run the Expert Advisor on its own chart.
}
 
Thank you you are the best as always!!!