Questions from a "dummy" - page 24

 
tol64:
Can I have a simple example?
show the code at which line the warning is issued. and what types it is swearing at
 
sergeev:
show the code on which line the warning is issued. and what types it frowns on

void OnStart()
  {
//--- выведем всю информацию, доступную из функции AccountInfoInteger()
   printf("ACCOUNT_LOGIN =  %d",AccountInfoInteger(ACCOUNT_LOGIN));
   printf("ACCOUNT_LEVERAGE =  %d",AccountInfoInteger(ACCOUNT_LEVERAGE));
   bool thisAccountTradeAllowed=AccountInfoInteger(ACCOUNT_TRADE_ALLOWED);
   bool EATradeAllowed=AccountInfoInteger(ACCOUNT_TRADE_EXPERT);

   ENUM_ACCOUNT_TRADE_MODE tradeMode=AccountInfoInteger(ACCOUNT_TRADE_MODE);           // На этой строке: Строка 25 Столбец 40 и Столбец 78
   ENUM_ACCOUNT_STOPOUT_MODE stopOutMode=AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE);   // И на этой     : Строка 26 Столбец 44 и Столбец 86

...
Highlighted and commented in the code.
 
tol64:

Highlighted and commented in the code.

   ENUM_ACCOUNT_TRADE_MODE tradeMode=(ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE);
   ENUM_ACCOUNT_STOPOUT_MODE stopOutMode=(ENUM_ACCOUNT_STOPOUT_MODE)AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE);

 
uncleVic:

Thank you. I would also like to ask about setting the stop out level mode. Can I only find out this mode as it is set by the trading server or can I change it?
 
tol64:
Thank you. I would also like to ask about setting the stop out level mode. I can only find out this mode because it is set by the trading server or can I change it?
Stop Out is read-only, you cannot set it. And everything that AccountInfo...() functions operate with is read-only.
 
tol64:

Highlighted and commented in the code.

Thank you, the example has been corrected. Now the compiler will not issue a warning on this example.
 

It turns out that wherever one needs to read certain data/properties one should apply the variant that uncleVic showed:https://www.mql5.com/ru/forum/3775/page24#comment_84143

For example, if you do so, which seems logical at first glance (and familiar from mql4 transition), then the compiler will generate a warning:

   int val_x_dist;
   int val_y_dist;
   
   Create_Label(0,"INFO","//-------------------- INFORMATION --------------------//",ANCHOR_RIGHT_UPPER,CORNER_RIGHT_UPPER,font,font_sz,fnt_clr_hdr,10,20);
   
   val_x_dist = ObjectGetInteger(0,"INFO",OBJPROP_XDISTANCE,0);
   val_y_dist = ObjectGetInteger(0,"INFO",OBJPROP_YDISTANCE,0);

To get rid of the compiler's warnings, you have to do either this:

   int val_x_dist;
   int val_y_dist;
   
   Create_Label(0,"INFO","//-------------------- INFORMATION --------------------//",ANCHOR_RIGHT_UPPER,CORNER_RIGHT_UPPER,font,font_sz,fnt_clr_hdr,10,20);
   
   val_x_dist = (ENUM_OBJECT_PROPERTY_INTEGER)ObjectGetInteger(0,"INFO",OBJPROP_XDISTANCE,0);
   val_y_dist = (ENUM_OBJECT_PROPERTY_INTEGER)ObjectGetInteger(0,"INFO",OBJPROP_YDISTANCE,0);

Or as uncleVic demonstrated, that is:

   Create_Label(0,"INFO","//-------------------- INFORMATION --------------------//",ANCHOR_RIGHT_UPPER,CORNER_RIGHT_UPPER,font,font_sz,fnt_clr_hdr,10,20);
   
   ENUM_OBJECT_PROPERTY_INTEGER val_x_dist = (ENUM_OBJECT_PROPERTY_INTEGER)ObjectGetInteger(0,"INFO",OBJPROP_XDISTANCE,0);
   ENUM_OBJECT_PROPERTY_INTEGER val_y_dist = (ENUM_OBJECT_PROPERTY_INTEGER)ObjectGetInteger(0,"INFO",OBJPROP_YDISTANCE,0);

Did I get it right?

 
AUser:
Can you tell me how the random number generator works and if there is a function to check the number for even/odd numbers? About the generator is desirable explanation in language understandable to dummies))) Help is not understood))

Here is the simplest example of how to find out what a particular function is doing. Run the script and look at the log.

void OnStart()
  {
   int x;
   
   x = MathRand();
   
   Print("x : ",x);
  }
 
#define Vrsn "0.01a"
#property version   Vrsn

ChartSaveTemplate(Chrt_Smbl_ID_Crrnt,Vrsn);

the template is saved as 0.tpl

#define Vrsn "001a"

The template is saved as001a.tpl, which is actually what you want to get.

Question: how do I remove the dot beforehand?

upgr probably more accurately: how do I find a character in a string?

upgr and another confusion. If there is a dot in

#define Vrsn "0.01a"

there's a dot, it not only cuts off what's after it, but also what's flattened.

ChartSaveTemplate(Chrt_Smbl_ID_Crrnt,Vrsn+Smbl_Crrnt);
Why? If StringToInteger is triggered at compilation ...
 
Silent:

the template is saved as 0.tpl

The template is saved as001a.tpl, which is actually what you want to get.

Question: how do I remove the dot beforehand?

upgr is probably more accurate: how do you find a character in a string?

There's also a misunderstanding. If in

there is a dot, it will cut off not only what's after it, but also what's flattened

why? if, presumably, StringToInteger is triggered at compile time.

Everything that is written to disk is necessarily checked for rubbish and maliciousness.

If you write a template, the template should be a file with the extension tpl, no matter what the user wanted. This is why the user defined dot in the name is cut out.