Questions from Beginners MQL5 MT5 MetaTrader 5 - page 343

 
barabashkakvn:

Change in the calculation code

to

That is 13 or 12 or some other number - this should be the "Period" parameter. Averaging period

Hooray!

Thank you it worked. Why this parameter is not in the original indicator? It is preset by default, do you know?

That is, I set only the number of bars for averaging and nothing else. In fact this is the only parameter in the source and it is used in the formula.

In the last version, I have two parameters. Number of bars for averaging and one for SmoothFactor calculation.

 
Alvin1976:

Hooray!

Thank you. But why isn't this parameter in the original indicator? Do you know if it is prescribed by default?

That is, I only set the number of bars for averaging and that's it. In fact, in the source code, this is the only parameter that is used in the formula.

In the last version, I have two parameters. Number of bars for averaging and one for SmoothFactor calculation.

Everything is available in the set. See indicator code "***\MQL5\Indicators\Examples\Custom Moving Average.mq5"
 
barabashkakvn:
Everything is in the delivery. See indicator code "***\MQL5\Indicators\Examples\Custom Moving Average.mq5".

That's where I got everything from :-). I guess I just don't understand.....

Still, for some reason the calculated EMA values do not add up to the original ones.

Maybe this indicator converted to a function is available somewhere?

 
Alvin1976:

That's where I got everything from :-). I guess I just don't understand.....

I want to use it as a handle and for some reason calculated EMA values do not coincide with original ones.

Maybe somewhere there is this indicator converted to a function ?

Or maybe it's better to create in OnInit() of the EA two handles of the iMA indicator with different types of smoothing and then just get the values of these indicators?

 
barabashkakvn:

Or maybe it's better to create two handles of iMA indicator with different types of smoothing in OnInit() and then just get the values of these indicators?

I already tried it. MQL5 produces some nonsense by handles. For example.

At the output at the first bar we get variable values even though the bar has already been formed! Everything works well in MQL4 but here is a mess.

     MAvarage1[ns] = INVALID_HANDLE;                        //-----------------------------------
   for (int i=0;i<10;i++) //10 попыток создать индикатор
      {
       MAvarage1[ns]=iMA(Symbols[ns],DopTF2,MAper1[ns],0,MAmet2,PRICE_CLOSE);
       if (MAvarage1[ns] == INVALID_HANDLE) Sleep(1000);
      }
              //Проверим handle 
   if (MAvarage1[ns] == INVALID_HANDLE) 
   {
    Print("Ошибка при создании MAvarage1! (№", GetLastError(), ")");
    return;
   } 

  Recount=false;
  if (CopyBuffer(MAvarage1[ns],0,0,2,MA1)<1) Recount=true;
  if (Recount){
  Print("Ошибка при копировании из индикатора ! (№", GetLastError(), ")");
  return;   
  }
  Print("MA1[1]=",MA1[1]);
 
Alvin1976:

I've already tried it. MQL5 produces some nonsense by handles. For example.

In this way, the first bar outputs variable values even though the bar has already been formed! Everything works fine in MQL4 but here it is horrible.

Forum on trading, automated trading systems and strategy testing

Questions from Beginners

I have never tried to use Handlestick in trading, it is too early to use it.

Or maybe it would be better to create two iMA indicator handles with different types of smoothing in OnInit() of the EA and then just get the values of these indicators?


 

I've already had a lot of trouble with transferring the code to MQL5. Mostly the problem is with the indicators. The stochastic is getting some kind of "lefty" values.

I have decided to calculate the values by myself.

I need MQL5 only for optimization speed and for checking multicurrency mode. That's all!

It is not useful for anything else. I hope that no dealing centre will ever use this "wonder".

I've got the variable values figured out! It turns out that CopyBuffer reverses the order of indices!

Why would I do that?

 

Alvin1976:

...Aaah with the variable values figured out ! CopyBuffer is reversing the order of the indices!

Why do I do that?

I don't want to ask the indicator what it doesn't need ... Imagine, you come to a newsstand. And you want some newspaper for the last 3 days... And they say, we'll sell your paper, but only for the last 20 days... Do you need it? :-)
 
denkir:
If you want to avoid asking the indicator what you don't need... Imagine, you come to a newsstand. And you need a newspaper from the last 3 days. And they say, "We can sell you your paper, but only for the last 20 days...". Do you need it? :-)

Well, in MQL4 you don't have to ask too much either. It's not about the quantity, it's about the order.

Where is the logic? Everyone has got used to the fact that the zero element of the array is the current bar. Why would you change something ????.

P.S. Fixed it through ArraySetAsSeries.

Tumbling .....

 
Alvin1976:

Well, in MQL4 you don't have to ask too much either. It's not about the quantity, it's about the order.

Where is the logic? Everyone has got used to the fact that the zero element of the array is the current bar. Why would you change something ????.

P.S. Fixed it through ArraySetAsSeries.

Dancing with tambourine.....

It's not the tambourine, it's the innovations you'll have to get used to. And these innovations will make the task easier in some cases. Don't ask about examples, I won't discuss it.
Reason: