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

 

And here's the interesting thing I noticed... I didn't pay attention to this difference.

In mql4, if you write this addition of strings through the StringConcatenate() function, then you get

eStr+=StringConcatenate(i,": ",eArray[i],", ");

and in mql5 it just

StringConcatenate(eStr, i, ": ", eArray[i], ", ");
Maybe I'm mistakenly not using this............
 
Alexey Viktorov:

I do not recommend to use this function because it works differently in MQL5 than in MQL4. Consequently, it may be hard to understand when you switch to MQL5


But maybe I'm wrong...

mql4

mql5

As you can see, mql5 is very similar to simple addition of strings.

And type conversion takes place in this function without any additional worries.

Yes, it's been discussed before.

of the three options StringAdd() , StringConcatenate() and pluses,

pluses are less costly.

 
ANDREY:

Why can't 1.6251 be cast to string as explicitly as i? It's shorter and saves computational resources..... it seems to me.

Thanks for the explanation.

Because such conversion can give a value of up to 16(if my brains haven't completely dried up) characters. And DoubleToString() "trims" the string to the specified number of decimal places. An integer i will remain an integer no matter how you spin it.

 
Alekseu Fedotov:

Yes, it was discussed once, I won't look for it

of the three options StringAdd() , StringConcatenate() and pluses,

pluses are less costly.

Maybe... But I'm not in favour of poking around such minor discrepancies.
 
TrederMT5:

Changed the code, still array out of range in the same place

Check if N in the array
double price[N];

always takes valid values?
 

Can you tell me how to make Print(), print once when the value changes

      string symbol;
      long currChart=ChartFirst(); int i=0;
      while(currChart>=0)
        {
         if(ChartGetInteger(currChart,CHART_BRING_TO_TOP,0)==true) 
           { 
            if(ChartSymbol(currChart)!=symbol)
              {
               symbol=ChartSymbol(currChart); Print(symbol);
              }
           } 
         currChart=ChartNext(currChart);  i++;
        }
 
MakarFX:

Tell me how to make Print(), print once when the value changes

Set counter

      string symbol;
      long currChart=ChartFirst(); int i=0;
      while(currChart>=0)
        {
         if(ChartGetInteger(currChart,CHART_BRING_TO_TOP,0)==true) 
           { 
            if(ChartSymbol(currChart)!=symbol)
              {
               i++;
               symbol=ChartSymbol(currChart); 
               if(i==1) Print(symbol);
              }
           } 
         currChart=ChartNext(currChart);
        }
 
Vitaly Muzichenko:

Set the meter

Thank you
 
Vitaly Muzichenko:

Set the meter

Doesn't work(
 
MakarFX:

Can you tell me how to make Print(), print once when the value changes

I like the boolean options better

 if(Work==false) // Критическая ошибка
     {
      if(AlertWork==false)   // Если Алерта еще не было
        {  Alert("Critical error. The expert Advisor doesn't work."); AlertWork=true; }
      return;
     }