Questions from Beginners MQL5 MT5 MetaTrader 5 - page 969

 
Sprut112:
The EA trades on a hedge. Maybe some checks should be added as standard?

Are you testing it on a cent account by any chance? On some cent accounts, the minimum lot is 0.1

 
Konstantin Nikitin:

I'm trading normally in the tester, build 1960. What lot I put, that's what it takes on 12 pairs at the same time

Why is #16 a 0.01 lot?
 
Konstantin Nikitin:

Are you testing on a cent account by any chance? On some cent accounts, the minimum lot is 0.1

No, there are checks on min max and lot increments
 
Sprut112:
And why #16 lot 0.01?

If you're referring to my picture, it's the partial closure in the expert that worked. It says close.

Sprut112:
No, checks for min max and lot increments.
So maybe this check looks for a minimum greater than the current one and substitutes it.
 
Konstantin Nikitin:

If you're referring to my picture, it's the partial closure in the expert that worked. It does say close

So maybe this check looks for a minimum greater than the current one and substitutes it.
We may think about it that way. It doesn't happen immediately in the tester, about a month later
 
Artyom Trishkin:

Why doesn't your code work as you want in mql4 with #property strict ?

What is such a fundamental difference from the code shown to you by Vladimir:

And there is no difference in these implementations. And there is only one reason for your code not to output text descriptions - it is absence of #property strict in mql4 code.


I didn't figure it out right away and thought it didn't work for me because of absence of =0, =1, etc...

enum MySymbol
     {
      symbol_0=0,// AUDUSD
      symbol_1=1,// NZDUSD
      symbol_2=2,// USDCAD
      symbol_3=3,// USDCHF
      symbol_4=4,// USDJPY
      symbol_5=5,// EURJPY
      symbol_6=6,// EURUSD
      symbol_7=7,// GBPUSD
      symbol_8=8,// #CL
     };

but it turned out to be the same thing...

string xx=EnumToString(Symboll_(1)); // result symbol_1

I should have gotten NZDUSD

  в таком варианте всё Ок но не получается добавить символ с решёткой #CL
enum  Symboll_
  {
   AUDUSD,
   NZDUSD,
   USDCAD
   //#CL
  };
string xx=EnumToString(Symboll_(1)); // результат NZDUSD

But the array variant is just what I needed...

 
xxz:

I didn't get it right away and thought I was failing because I didn't have =0, =1, etc...

but it turned out to be the same thing...

string xx=EnumToString(Symboll_(1)); // result symbol_1

I should have gotten NZDUSD

But this array variant is just what I needed...

Naturally, when outputting an enumeration via EnumToString(), you will not get a description of the variable behind the "//" but the variable itself as it is.

To print the enumeration the way you want, you need to make a function analog to EnumToString(), which will print it.

For an enumeration like this:

enum ENUM_SYMBOL_NAMES
  {
   SYMBOL_NAME_AUDUSD,     // AUDUSD
   SYMBOL_NAME_NZDUSD,     // NZDUSD
   SYMBOL_NAME_USDCAD,     // USDCAD
   SYMBOL_NAME_USDCHF,     // USDCHF
   SYMBOL_NAME_USDJPY,     // USDJPY
   SYMBOL_NAME_EURJPY,     // EURJPY
   SYMBOL_NAME_EURUSD,     // EURUSD
   SYMBOL_NAME_GBPUSD,     // GBPUSD
   SYMBOL_NAME_SHARP_CL,   // #CL
  };
input ENUM_SYMBOL_NAMES InpNames; // Instrument

Like this:

//+------------------------------------------------------------------+
string InstrumentToString(void)
  {
   string enm=EnumToString(InpNames);
   int index=StringFind(enm,"SHARP_");
   int shift=(index>WRONG_VALUE ? index+6 : 12);
   string name=StringSubstr(enm,shift);
   return(index>0 ? "#"+name : name);
  }
//+------------------------------------------------------------------+

And call:

Print(InstrumentToString());
 
double get_lot(int pair, double input_lots) {
   if(input_lots<min_lot[pair]) return(min_lot[ir]);
   return(input_lots);
 
Konstantin Nikitin


:

If you're referring to my picture, it's the partial closure in the expert that worked. It says close.

So maybe this check looks to see if the minimum is greater than the current one and substitutes it.
 if(SymbolInfoDouble(Symb,SYMBOL_VOLUME_STEP)<0.1) dg=2; else
      if(SymbolInfoDouble(Symb,SYMBOL_VOLUME_STEP)<1.0) dg=1;

I don't think that's right.

 
Vladimir Karputov:

Better still, clearly state what you want to achieve. I'll probably give you a complete example.

Once upon a time, back in 2010, in winter. I also asked to filter in an indicator, the essence of which: to draw the Mach & Min HLine with PERIOD_MN1 for iBars....))))

I figured it out on my own. Mastered MT4.

Slowly, not immediately, I am mastering MT5.

...."Clearly state what you want to get" FORMULA: I am converting (myself) what I programmed (myself) and at the same time I am mastering (myself) MT5 ))))


BUT what you showed me with examples (visually) has NOT gone away.


IF SO I'll go back )))

If SHO, I'll go back






 
Artyom Trishkin:

Naturally, when printing out an enumeration using EnumToString(), you will not get a description of the variable, which is behind "//", but the variable itself as it is.

To print it out the way you want, you need to make a function analog to EnumToString(), which will print it out.


This is the trouble, because to solve the simplest task you have to create a function and this is a heap of code nobody needs,

instead of one line of ten...

I'm trying to be as succinct as possible!...

I could originally get around this problem by adding just one line to the code

            xx=iClose(Symbol_(i),0,50);
xx=iClose("#CL",0,50);

but I didn't like it just because of the extra line in the code...

I don't like "dirty" code...