Questions from Beginners MQL5 MT5 MetaTrader 5 - page 783

 
Vitaly Muzichenko:

Thank you for your attention.

The general view of the indicator is like this, and how to do it withoutiEnvelopesOnArray andiBandsOnArray is absolutely unclear


Why should it be done without them? Well, make your own calculation based on the buffer data. But the calculation should then repeat the same calculation as the ones you want to discard.

 
Artyom Trishkin:

Why not? Well, do your own calculation based on the buffer data. But the calculation must then repeat the same calculation as the ones you want to discard.

No one would refuse from them, but they take only handles, not arbitrary arrays as in mql4

 
Alexey Viktorov:

No one would refuse them, but they only accept handles, not arbitrary arrays as in mql4

I see, I'm confused. I thought it was a question about mql4.
 
Artyom Trishkin:
I see. I was confused. I thought it was about four.

The question is about translating to five, and the goal is to get a similar display as now on four

Here is a more complete code, the symbols are substituted in the indicator by pressing buttons on the chart, that is, Inite is not enough

  for(int i=0; i<limit; i++) {
    Last[i] = Symbol1_Vol*Vol1*iClose(Symbol1_Name,0,iBarShift(Symbol1_Name,0,Time[i])) - 
              Symbol2_Vol*Vol2*iClose(Symbol2_Name,0,iBarShift(Symbol2_Name,0,Time[i]));
  }

 for(int i=0; i<limit; i++) {
    if(ButtonSt) { // кнопка выбора, отображать Bands, или Envelopes
     MA[i]=iMAOnArray(Last,0,Env_Period,0,MODE_SMA,i);
     LineUp[i]=iEnvelopesOnArray(Last,0,Env_Period,MODE_SMA,0,Env_Dev,MODE_UPPER,i);
     LineDn[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);
     LineUp[i]=iBandsOnArray(Last,0,BB_Period,BB_Dev,0,MODE_UPPER,i);
     LineDn[i]=iBandsOnArray(Last,0,BB_Period,BB_Dev,0,MODE_LOWER,i);
    }
  }

How do you translate this to fives? Or it is impossible due to lack of functionality in it?

 
Vitaly Muzichenko:

The question is about translating to five, and the goal is to get a similar display as now on four

Here is a more complete code, the symbols are substituted in the indicator by pressing buttons on the chart, that is, Inite is not enough

How do you translate this to fives? Or it is impossible due to the lack of functionality in it?

So no one is imposing to get the handle in the inite...

 
Alexey Viktorov:

So no one is imposing to get the handle in the inite...

I don't mind)

I can't figure out how to replaceiEnvelopesOnArrayandiBandsOnArray at all, as it's not in Five, and I have no idea where to start. I need to get a completely identical mapping in MT5

 
Vitaly Muzichenko:

I don't mind)

I can't figure out how to replaceiEnvelopesOnArrayandiBandsOnArray at all, as it's not in Five, and I have no idea where to start. I need to get a fully identical mapping in MT5

Because it's not the first time you have ignored it.

Forum on Trading, Automated Trading Systems & Strategy Tests

FAQ from Beginners MQL5 MT5 MetaTrader 5

Alexey Viktorov, 2017.09.21 20:06

There is MovingAverages.mqh in the root of include but I haven't looked for BB, maybe not. But the best option is to stick the data source indicator handle as price in iMA function.

I have an example with only smoothed iMA

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 after receiving its handle to insert it to iMA and other functions.

What a mess...


 
Alexey Viktorov:

Because it's not the first time you've ignored what you've written

There's MovingAverages.mqh in the root of include, but I haven't looked for BB, maybe not.
There is: \MQL5\Include\Indicators\Trend.mqh
 
Artyom Trishkin:
Got it: \MQL5\Include\Indicators\Trend.mqh

Thank you, I've found it now.

I had to apply iTEMA to custom indicator, but I didn't think to look there... I did as described above, everything works without any problems.

 

Please help me with making up a function.

I have a current TF and an estimated TF, the function should return the difference between the two TFs in any combinations, if the measurement were in bars

Calculation TF 15 15 15 60 60 60 240 240 240
Current TF 15 5 1 15 5 1 60 15 5
Difference in Nbar 1 3 15 4 12 60 4 16 48

How to implement this correctly?

Reason: