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

 
Victor Nikolaev:


if by year, it may go something like this

Original - thank you! By quarters would have to control the number of days in each quarter, adjusted for leap year, apparently...


Victor Nikolaev:


It works

2017.03.20 21:39:02.802 StringReplace EURUSD,M15: 999.99 = 999.99

Hmm..., where is the logic or description in the help that another string variable should be created - I guess I should figure it out myself...

Thanks for the example.

 
-Aleks-:

Original - thank you! By quarters I'll have to control the number of days in each quarter, corrected for the leap year, apparently...


Hmm..., where's the logic or description in the helpe of the fact that another string variable has to be created - well, I guess I'll have to figure it out myself...

Thanks for the example.

You don't need another variable. The result is written to the existing one. Victor just saved its initial value, nothing more.
 
Artyom Trishkin:
You don't need another variable. The result is written to the existing one. Victor just saved its initial value, nothing more.

Then I can't understand why I don't have a comma in my case...
 
-Aleks-:

Then I can't understand why I don't have a comma in my case...

Look at what StringReplace() returns.

And then think about what value you're assigning to str_avrMassSell

 
Artyom Trishkin:

Look at what StringReplace() returns.

And then think about what value you're assigning to str_avrMassSell

I convert a number to a string and then look for a full stop and change it to a comma - what am I doing wrong?


//+------------------------------------------------------------------+
//|                                                StringReplace.mq4 |
//|                                            Copyright 2017, Vinin |
//|                                             http://vinin.ucoz.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Vinin"
#property link      "http://vinin.ucoz.ru"
#property version   "1.00"
#property strict
#property script_show_inputs
//--- input parameters
input double   Temp=999.99;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   string stemp1=DoubleToString(Temp,2);
   string stemp2=stemp1;
   StringReplace(stemp2,".",",");
   Print(stemp1," = ", stemp2);
   double avrMassSell=Temp;
   string str_avrMassSell=DoubleToString(avrMassSell,2);
   str_avrMassSell=StringReplace(str_avrMassSell,".",",");
   Print ("str_avrMassSell=",str_avrMassSell);
   
  }
//+------------------------------------------------------------------+
 
-Aleks-:

I convert a number to a string and then look for a full stop and change it to a comma - what am I doing wrong?


Look in the help to see what StringReplace() returns ?
 
Artyom Trishkin:
And have a look in the help to see what StringReplace() returns ?

Here... Are there any other functions like this? Became a victim of stereotypical thinking...
 
-Aleks-:

Here... are there more functions like this? Fallen victim to stereotypical thinking...
Maybe there are - I can't remember everything. I remembered this one because long ago, at the dawn of my career, I ran into the same thing myself. Now, if I don't remember something, I always look at the help, thanks to the fact that it's not hard to put the cursor on a function and press F1
 
Artyom Trishkin:
Maybe there are some - I can't remember everything. About this remembered because a long time ago, at the dawn of the formation, myself ran into the same thing. If I can't remember anything, I always consult the Help. Thank goodness it's not hard to put the cursor on a function and press F1.

Yeah, you should be more careful - I used the helpline to find the function, but I didn't read everything, which is why I paid the price...

Thanks for the tip.

 
Dear forum users!
I downloaded an Expert Advisor from the internet, the idea of which has interested me. After fixing a few bugs in the code, it translated it without errors or warnings. However, when trying to test it, I have encountered the absence of the "Input parameters" tab in the Expert Advisor Properties window. When testing other Expert Advisors, there is no such problem. The Expert Advisor does not use any include files or libraries. There are no #include and #import directives in the code. I have not found in the available documentation and forums any information about what else the lack of this tab may be related to (except for the use of the above mentioned directives).
The situation is at an impasse. I am attaching the screenshot of the Expert Advisor "hat" with directives and input parameters, just in case.
SOS!