Features of the mql4 language, subtleties and techniques - page 21

 
fxsaber:

Profitability calculation.


Applying


Result


ZZZ I do not know how to get rid of the quacky characters (copied from MT4 Experts tab).

Switch the terminal to Russian.
 
Artyom Trishkin:
Switch the terminal to Russian.

The terminal and everything in it is in Russian. There are crocodiles when copying.

 
fxsaber:

The terminal and everything in it is in Russian. There are crocodiles when copying.

The keyboard layout when copying should be in Russian.

 
Artyom Trishkin:

The keyboard layout when copying should be in Russian.

Thank you, it worked.

 
Artyom Trishkin:

The keyboard layout when copying should be in Russian.

Artem, and in what way it can influence at all ? it is BAG
 
Maxim Kuznetsov:
Artyom, how can this have any effect at all? This is a BAG

It's been like this for as long as I can remember here and at mql4.com.

 
Artyom Trishkin:

This has been happening as long as I can remember here and at mql4.com.

i.e. it became a FICTION :-)

How the hell can the state of input language switch affect the result of Copy-Paste?

 
Yurij Kozhevnikov:
That should go in 'Features'. I wouldn't have minded learning about it a few years earlier.
It's already here - in the special features.
 
Artyom Trishkin:
It's already there - in features.

Then I noticed :D

That's why I deleted it.

 
Risk calculation.
// Вычисляет риск для заданной максимальной просадки.
double GetRisk( const double NewMaxDD, const double Alpha, const string Symb, const int Magic = -1  )
{
  double RiskLeft = 0;
  double RiskRight = 10;
  
  double Risk, SumGain, MaxDD, RF;
    
  do
  {
    Risk = (RiskLeft + RiskRight) / 2;
        
    if (!GetSumGain(Risk, SumGain, MaxDD, RF, Symb, Magic)) // https://www.mql5.com/ru/forum/170953/page20#comment_13432058
    {
      MaxDD = DBL_MAX;

      RiskRight = Risk;      
    }
    else if (MaxDD > NewMaxDD)
      RiskRight = Risk;
    else
      RiskLeft = Risk;
  }
  while (!IsStopped() && (MathAbs(MaxDD - NewMaxDD) > Alpha));
  
  return(Risk);  
}


Application.

#property strict
#property  show_inputs

input double inMaxDD = 0.3; // Для какой максимальной просадки вычислить риск?
input int MagicNumber = 1;

#define  D(A) DoubleToString(A, 2)

void OnStart()
{
  double SumGain, MaxDD, RF;
  
  const double Risk = GetRisk(inMaxDD, 0.01, _Symbol, MagicNumber);
  
  if (GetSumGain(Risk, SumGain, MaxDD, RF, _Symbol, MagicNumber))   
    Print((string)MagicNumber + ": при риске " + D(Risk) +
                                " увеличение было бы в " + D(SumGain) + " раза" +
                                " с максимальной относительной просадкой по балансу " + D(MaxDD) + 
                                ", фактор восстановления = " + D(RF));  
}


Result

1: при риске 0.51 увеличение было бы в 3.82 раза с максимальной относительной просадкой по балансу 0.30, фактор восстановления = 3.20
Reason: