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

 

You could do this: the immutable part of the name in front, then "RED-LINE", then the modifiable part of the name.

Now the prefix would be: the immutable part of the name plus "RED-LINE".

 
Aleksei Stepanenko:

You could do this: the immutable part of the name in front, then "RED-LINE", then the modifiable part of the name.

Now the prefix would be: the immutable part of the name plus "RED-LINE".

There, what's in front is also changeable. so far the question is exactly what'sin the middle of the name.

 
Andrey Sokolov:

What's in the front changes as well. The question is exactly what'sin the middle of the title.

You can't make fun of someone who's trying to help you...

Where are the objects created? How is the name of the object formed?

 
Alexey Viktorov:

You can't make fun of someone who's trying to help you...

OK

 

Question aboutiMAOnArray()

There is a code, how to apply it in mql5 ?

   double buff[1];
   for(i = 0; i < counter; i++)
      Array[i] = 2.0 * ma(i, val) - ma(i, a);
   for(i = 0; i < counter - a; i++)
     // buf_3[i] = iMAOnArray(Array, 0, period, 0, MODE_SMMA, i); // Оригинал mql4
      buf_3[i] = iMA(NULL, 0, period, 0, MODE_SMMA, PRICE_LOW); ???
      CopyBuffer(10,0,i,1,buff); ???
      buf_3[i] = buff[0];
 

Hello.

Can you tell me how to make a "window" in the EA where you could enter a certain price so that the EA could work with it afterwards. (See picture)

Files:
GBPUSDM5.png  35 kb
 
SanAlex:

Here's a way -- found herehttps://www.mql5.com/en/articles/81

I read that, it's too heavy and unoptimised

 
SanAlex:

Here's a way -- found herehttps://www.mql5.com/en/articles/81

It's not the best way

 
Vitaly Muzichenko:

Question aboutiMAOnArray()

There is a code, how to apply it in mql5 ?

   double buff[1];
   for(i = 0; i < counter; i++)
      Array[i] = 2.0 * ma(i, val) - ma(i, a);
   for(i = 0; i < counter - a; i++)
     // buf_3[i] = iMAOnArray(Array, 0, period, 0, MODE_SMMA, i); // Оригинал mql4
      buf_3[i] = iMA(NULL, 0, period, 0, MODE_SMMA, PRICE_LOW); ???
      CopyBuffer(10,0,i,1,buff); ???
      buf_3[i] = buff[0];

Array[] should be a buffer (if it is an indicator)

Now look in the standard package: \MQL5\Include\MovingAverages.mqh - there is a calculation on the buffer such-MAOnBuffer()

 
Artyom Trishkin:

Array[] must be a buffer (if it is an indicator)

Now take a look at the standard package: \MQL5\Include\MovingAverages.mqh - there is a calculation on the buffer such-MAOnBuffer()

Thank you!

Tried it and got an error, I'm doing something wrong:

  double buff[];
   for(i = 0; i < counter; i++)
      Array_1[i] = 2.0 * ma_1(i, val_1) - ma_1(i, a);
   for(i = 0; i < counter - a; i++) {
      // buf_3[i] = iMAOnArray(Array_1, 0, period, 0, MODE_SMMA, i);
      SmoothedMAOnBuffer(rates_total, prev_calculated, i, period, Array_1, buff);
      buf_3[i] = buff[0];
   }
....

//+------------------------------------------------------------------+
int SmoothedMAOnBuffer(const int rates_total,const int prev_calculated,const int begin,const int period,const double& price[],double& buffer[])
{
//--- check period
   if(period<=1 || period>(rates_total-begin))
      return(0);
//--- save as_series flags
   bool as_series_price=ArrayGetAsSeries(price);
   bool as_series_buffer=ArrayGetAsSeries(buffer);
   ArraySetAsSeries(price,false);
   ArraySetAsSeries(buffer,false);
//--- calculate start position
   int start_position;
   if(prev_calculated==0) { // first calculation or number of bars was changed
      //--- set empty value for first bars
      start_position=period+begin;
      for(int i=0; i<start_position-1; i++)
         buffer[i]=0.0; // array out of range (188,16)
      //--- calculate first visible value
      double first_value=0;
      for(int i=begin; i<start_position; i++)
         first_value+=price[i];
      buffer[start_position-1]=first_value/period;
   } else
      start_position=prev_calculated-1;
//--- main loop
   for(int i=start_position; i<rates_total; i++)
      buffer[i]=(buffer[i-1]*(period-1)+price[i])/period;
//--- restore as_series flags
   ArraySetAsSeries(price,as_series_price);
   ArraySetAsSeries(buffer,as_series_buffer);
//---
   return(rates_total);
}
//+------------------------------------------------------------------+
Reason: