Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 47

 
Artyom Trishkin:

If you add comments to each line, it will be more interesting:

input    int      MetaQuotes1    =  30;         // Описание входного параметра 1
input    bool     MetaQuotes2    =  true;       // Описание входного параметра 2
input    double   MetaQuotes3    =  20.3;       // Описание входного параметра 3
input    string   MetaQuotes4    =  "Corp";     // Описание входного параметра 4

And if you make another enumeration and use it instead of a bool, it's even more interesting:

enum enumYN
  {
   enYes =  1,    // Да
   enNo  =  0,    // Нет
  };

input    int      MetaQuotes1    =  30;         // Описание входного параметра 1
input    enumYN   MetaQuotes2    =  enYes;      // Описание входного параметра 2
input    double   MetaQuotes3    =  20.3;       // Описание входного параметра 3
input    string   MetaQuotes4    =  "Corp";     // Описание входного параметра 4

and sinput allows you to exclude a variable from the list of variables for optimization. For example, MetaQuotes4 variable in this context is not necessary for optimization and it can be excluded:

enum enumYN
  {
   enYes =  1,    // Да
   enNo  =  0,    // Нет
  };

input    int      MetaQuotes1    =  30;         // Описание входного параметра 1
input    enumYN   MetaQuotes2    =  enYes;      // Описание входного параметра 2
input    double   MetaQuotes3    =  20.3;       // Описание входного параметра 3
sinput   string   MetaQuotes4    =  "Corp";     // Описание входного параметра 4

There is nothing wrong with this, we just needed to add text to make it clear during optimization from and to which parameter and step.

 
Mikhail Goryunov:
There is nothing wrong with this, all that was required was to add text to make it clear when optimising from and to which parameter and step.
OK. But there are others who didn't know ;)
 
why do they write it that way, what do they assign? int tik=OrderSend
 
wishmast:
why do they write this as an assignment? int tik=OrderSend
Because
Возвращаемое значение

Возвращает номер тикета, который назначен ордеру торговым сервером или -1 в случае неудачи. Чтобы получить информацию об ошибке, необходимо вызвать функцию GetLastError().

The value of this variable will then determine what you do next. For example

      double ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),digits);
      price=NormalizePrice(_Symbol,ask+Distance*_Point);
      t=OrderSend(_Symbol,OP_BUYSTOP,volume,price,Slippage,0,0,CommentOrder,Magic,0,clrBlue);
      if(t<0)
        {
         error=GetLastError();
         rezult=StringConcatenate(_Symbol,": error open order ",DoubleToString(volume,2)," ",TypeToStr(type)," №- ",error," ",ErrorDescription(error));
         Print(rezult);
        }
      else
        {
         tiket=t;
         rezult=StringConcatenate(_Symbol,": open order ",t," ",DoubleToString(volume,2)," ",TypeToStr(type));
         Print(rezult);
         SendNotification(rezult);
        }


....

 
Artyom Trishkin:

and sinput allows you to exclude a variable from the list of variables to be optimised. For example, the variable MetaQuotes4 is not needed for optimisation in this context and can be excluded:


sinput   string   MetaQuotes4    =  "Corp";     // Описание входного параметра 4
Unfortunate example, lowercase parameters will not be involved in optimization in any way.
 
Vitalie Postolache:
Unfortunate example, lowercase parameters will not be involved in optimisation in any way.
I did not choose them by success/failure. I just showed you an example of the code I've written above. The example was clear. That's what I was trying to do.
 
Artyom Trishkin:
I didn't pick it up by success/failure. I just showed you an example of the above code. The example was clear. That's what I was trying to do.

Absolutely right, you can do that as well.

input string   MetaQuotes4    =  "Corp";
 
Mikhail Goryunov:

Absolutely right, you can do that too

input string   MetaQuotes4    =  "Corp";
You could. Who's stopping you? My purpose was to talk about sinput. I did. Well, the example is a bit unfortunate, but it doesn't change the point.
 

Here is a construction.

doubleiLowest(string symbol,ENUM_TIMEFRAMES timeframe,int ne)

Question: what type doesENUM_TIMEFRAMES have?

 
Vitaly Muzichenko:

Here is a construction.

doubleiLowest(string symbol,ENUM_TIMEFRAMES timeframe,int ne)

Question: what type doesENUM_TIMEFRAMES have?

This is enum