Questions from Beginners MQL5 MT5 MetaTrader 5 - page 782

 
LookingFor:

Colleagues, MathSum function, description here

https://www.mql5.com/ru/docs/standardlibrary/mathematics/stat/mathsubfunctions/statmathsum

is not recognized in build 1643 . Do I have to tear everything down and update it?

#include <Math\Stat\Math.mqh>
 

Please help in solving the problem.

Each iteration of the loop in the script needs to be executed with a selected delay, how can this be implemented?

 
Aleksey Vyazmikin:

Please help in solving the problem.

Each iteration of the loop in the script needs to be executed with a selected delay, how can this be implemented?

for(...)
  {
   ...
   Sleep();
  }
 
Alexey Kozitsyn:

Thank you! I had completely forgotten about this possibility!

 
I wanted to ask how to enable trailing stops in the mt5 tester, it opens but does not trail, I do not understand whether it is a broker or a new terminal, I do not understand
 
Viktor Pavlov:
I wanted to ask how to enable trailing stop in the mt5 tester, it opens but does not trailing stop, I do not understand if it is the broker or a new terminal, I do not understand

Trailing Stop

 

Help me translate it, I tried to find it myself, but it didn't work - I couldn't find any analogues

 for(int i=0; i<limit; i++) {
    if(ButtonSt) {
     MA[i]=iMAOnArray(Last,0,Env_Period,0,MODE_SMA,i);
     EnvUp[i]=iEnvelopesOnArray(Last,0,Env_Period,MODE_SMA,0,Env_Dev,MODE_UPPER,i);
     EnvDn[i]=iEnvelopesOnArray(Last,0,Env_Period,MODE_SMA,0,Env_Dev,MODE_LOWER,i);
    } else {
     MA[i]=iMAOnArray(Last,0,BB_Period,0,MODE_SMA,i);
     EnvUp[i]=iBandsOnArray(Last,0,BB_Period,BB_Dev,0,MODE_UPPER,i);
     EnvDn[i]=iBandsOnArray(Last,0,BB_Period,BB_Dev,0,MODE_LOWER,i);
    }
  }
 
Vitaly Muzichenko:

Please tell me how to translate it, I tried to find it myself, but it didn't work - I couldn't find any analogues

There is a buffer Last[]. It is already filled in the first loop. Then, depending on the state of button (probably, since the variable is called ButtonSt) three more buffers are filled in the loop based on Last[] buffer, but with different values of different indicators.

//--- если кнопка нажата
if(ButtonSt) {
  //--- нарисовать MA с периодом Envelopes на данных линии буфера Last
  MA[i]=iMAOnArray(Last,0,Env_Period,0,MODE_SMA,i);
  //--- нарисовать верхнюю линию Envelopes на данных линии буфера Last
  EnvUp[i]=iEnvelopesOnArray(Last,0,Env_Period,MODE_SMA,0,Env_Dev,MODE_UPPER,i);
  //--- нарисовать нижнюю линию Envelopes на данных линии буфера Last
  EnvDn[i]=iEnvelopesOnArray(Last,0,Env_Period,MODE_SMA,0,Env_Dev,MODE_LOWER,i);
//--- если кнопка не нажата
 } else {
  //--- нарисовать MA с периодом Bollinger Bands на данных линии буфера Last
  MA[i]=iMAOnArray(Last,0,BB_Period,0,MODE_SMA,i);
  //--- нарисовать верхнюю линию Bollinger Bands на данных линии буфера Last
  EnvUp[i]=iBandsOnArray(Last,0,BB_Period,BB_Dev,0,MODE_UPPER,i);
  //--- нарисовать нижнюю линию Bollinger Bands на данных линии буфера Last
  EnvDn[i]=iBandsOnArray(Last,0,BB_Period,BB_Dev,0,MODE_LOWER,i);
 }
 
Artyom Trishkin:

There is a buffer Last[]. It is already filled in the first loop. Then, depending on button state (probably, since the variable is called ButtonSt) three more buffers are filled in the loop based on Last[] buffer, but with different values of different indicators.

Thank you for your attention.

The general view of the indicator is like this, I have absolutely no idea how to do it withoutiEnvelopesOnArray andiBandsOnArray.


 
Vitaly Muzichenko:

Please tell me how to translate it, I tried to find it myself, but it didn't work - I couldn't find any analogues.

I have MovingAverages.mqh in the root of include, but I haven't looked for BB, maybe not. But the best way to do it is to insert indicator handle of data source as a price in iMA function.

I have an example with smoothed iMA only

int haMa8, haFastMa, haMa21, haSlowMa;

int OnInit()
 {
   haMa8  = iMA(_Symbol, PERIOD_CURRENT, perFastMa, 0, metodFastMa, priceFastMa);
   haFastMa = iMA(_Symbol, PERIOD_CURRENT, perFastMa, 0, metodFastMa, haMa8);
   
   haMa21 = iMA(_Symbol, PERIOD_CURRENT, perSlowMa, 0, metodSlowMa, priceSlowMa);
   haSlowMa = iMA(_Symbol, PERIOD_CURRENT, perSlowMa, 0, metodSlowMa, haMa21);

//Продолжение догадаешься

The same for BB.

If the source is a custom indicator, then you have to

  • Make it separately.
  • Create a new indicator.
  • Attach the first one as a resource.
  • And then after getting its handle to iMA and other functions.

What a mess...

Reason: