[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 56

 
Good afternoon, please help, there is a simple idea to implement an Alert() call when three MAs intersect.
Description of the intersection in the program. It seems to work, but not as it should. I am rounding the variables to one digit so that
will catch the intersection. And this Alert() drums me as long as the means are at the same position. How do I make it get called once, well up to 5 times.
//+------------------------------------------------------------------+
//| Глобальные переменные                                  |
//+------------------------------------------------------------------+
   extern int Period_MA_Blue = 4;         // Период 4-х расчётной синей МА (4 часа)
   extern int Period_MA_Green = 13;       // Период 13-ти расчётной зеленой МА (13 часов)
   extern int Period_MA_Orange = 50;      // Период 50-ти расчётной оранжевой МА (2 дня 2 часа)
   double MA_Blue_EURUSD, MA_Green_EURUSD, MA_Orange_EURUSD;
   string SMA_Blue_EURUSD,SMA_Green_EURUSD,SMA_Orange_EURUSD;

//+------------------------------------------------------------------+
//| Начало программы                                  |
//+------------------------------------------------------------------+

int init(){return(0);}
int EURUSD()
      {
  
      if(SMA_Green_EURUSD == SMA_Orange_EURUSD && SMA_Blue_EURUSD > SMA_Orange_EURUSD)
         {
          // Если зеленая МА пересекает оранжевую МА и при этом синяя МА выше - сигнал к покупке.
          Alert("Cигнал на ПОКУПКУ паре EURUSD");
          return(11); // 11 - на первой паре сигнал на покупку.
         }
  
      if(SMA_Green_EURUSD == SMA_Orange_EURUSD && SMA_Blue_EURUSD < SMA_Orange_EURUSD)
         {
          // Если зеленая МА пересекает оранжевую МА и при этом синяя МА ниже - сигнал к продаже.
          Alert("Cигнал на ПРОДАЖУ паре EURUSD");
          return(10); // 20 - на первой паре сигнал на продажу.
         }     
      }
int start()

   {

//+------------------------------------------------------------------+
//| Блок работы с EURUSD                               |
//+------------------------------------------------------------------+
   if(EURUSD() != 11 || EURUSD() != 10)
      {
         // Если функция EURUSD() не зафиксировала ни один из сигналов, обрабатываем данные дальше.
         MA_Blue_EURUSD = iMA("EURUSD",PERIOD_H1,Period_MA_Blue,0,MODE_EMA,PRICE_CLOSE,0);
         MA_Green_EURUSD = iMA("EURUSD",PERIOD_H1,Period_MA_Green,0,MODE_EMA,PRICE_CLOSE,0);
         MA_Orange_EURUSD = iMA("EURUSD",PERIOD_H1,Period_MA_Orange,0,MODE_EMA,PRICE_CLOSE,0);
  
         SMA_Blue_EURUSD = MA_Blue_EURUSD;
     // Преобразование int в string
         SMA_Blue_EURUSD = StringSetChar(SMA_Blue_EURUSD, 6, '');     // Округление до х.хххх
         SMA_Green_EURUSD = MA_Green_EURUSD;   // Преобразование int в string
         SMA_Green_EURUSD = StringSetChar(SMA_Green_EURUSD, 6, '');   // Округление до х.хххх
         SMA_Orange_EURUSD = MA_Orange_EURUSD; // Преобразование int в string
         SMA_Orange_EURUSD = StringSetChar(SMA_Orange_EURUSD, 6, ''); // Округление до х.хххх

      }

     }

int deinit(){return(0);}




If it's all wrong on the root, suggest methods to track the intersection. Thanks.
 
Zherart:
Good afternoon, please help, there is a simple idea to implement an Alert() call when three MAs intersect.
Description of the intersection in the program. It seems to work, but not as it should. I am rounding the variables to one digit to
to catch the intersection. And this Alert() drums up to me as long as the means are at the same position. How do I make it get called once, well up to 5 times.If it's not right at the root, suggest methods to track the intersection. Thank you.

//+------------------------------------------------------------------+
//| Глобальные переменные                                  |
//+------------------------------------------------------------------+
   extern int Period_MA_Blue = 4;         // Период 4-х расчётной синей МА (4 часа)
   extern int Period_MA_Green = 13;       // Период 13-ти расчётной зеленой МА (13 часов)
   extern int Period_MA_Orange = 50;      // Период 50-ти расчётной оранжевой МА (2 дня 2 часа)
   double MA_Blue_EURUSD, MA_Green_EURUSD, MA_Orange_EURUSD;
   string SMA_Blue_EURUSD,SMA_Green_EURUSD,SMA_Orange_EURUSD;
   int БАРАБАНИТЬ = 1; // Сколько раз подавать сигнал
   int ПОКУПКА=0,ПРОДАЖА=0;
//+------------------------------------------------------------------+
//| Начало программы                                  |
//+------------------------------------------------------------------+

int init(){return(0);}
int EURUSD() 
      {
   
      if(SMA_Green_EURUSD == SMA_Orange_EURUSD && SMA_Blue_EURUSD > SMA_Orange_EURUSD)
         { 
          // Если зеленая МА пересекает оранжевую МА и при этом синяя МА выше - сигнал к покупке.
          if(ПОКУПКА<БАРАБАНИТЬ) {Alert("Cигнал на ПОКУПКУ паре EURUSD");ПОКУПКА++;}
          return(11); // 11 - на первой паре сигнал на покупку.
         }
      else ПОКУПКА=0;
      if(SMA_Green_EURUSD == SMA_Orange_EURUSD && SMA_Blue_EURUSD < SMA_Orange_EURUSD)
         { 
          // Если зеленая МА пересекает оранжевую МА и при этом синяя МА ниже - сигнал к продаже.
          if(ПРОДАЖА<БАРАБАНИТЬ) {Alert("Cигнал на ПРОДАЖУ паре EURUSD");ПРОДАЖА++;}
          return(10); // 20 - на первой паре сигнал на продажу.
         }
       else ПРОДАЖА=0;       
      }

Somewhere like this at a glance...
 
Sepulca, thank you!!! We'll give it a try. Got the point!!!
 
Either I'm stupid or there's something wrong with the terminal. I wanted to optimise an EA, but there is no "input parameters" tab in the EA properties. Help.
 
prom18:
Either I'm stupid or there's something wrong with the terminal. I wanted to optimise an EA, but there is no "input parameters" tab in the EA properties. I've been trying to optimise my EA, but there is no "input parameters" tab in its properties.



https://forum.mql4.com/ru/46980/page417#702426

https://www.mql5.com/ru/forum/138609/page417#702426

 

Is it possible to use an array in the parameters of a function? For example, I want to create a function that handles information in an array:

void Function(double Array[])
 {
  ...
 }
 
silhouette:

Is it possible to use an array in the parameters of a function? For example, I want to create a function that handles information in an array:


What does the tutorial say here?

"

The parameters to be passed are indicated in parentheses after the name of the function to be called and are listed, separated by commas. The number of parameters passed to a function must not exceed 64. The function may also not use the passed parameters. In this case, an empty parameter list is indicated, i.e. opening and closing parentheses are placed immediately after the function name.

The number, type and order of the parameters passed in the function call must coincide with the number, type and order of formal parameters, specified in the function description (exception is the call of a function, which has default parameters - see Function call and Function description and return operator). If there is no such coincidence, the MetaEditor will output an error message. Constants, variables, expressions and arrays can be used as passed parameters. "

 
silhouette:

Is it possible to use an array in the parameters of a function? For example, I want to create a function that handles information in an array:

Try this:

void Function(double& Array[])
 {
  ...
 }
https://docs.mql4.com/ru/basis/variables/formal
 
Sepulca:


Same goes for Close - iClose, Open - iOpen, Time - iTime Volume - iVolume etc.

And the indicator can draw up to 8 lines from 0 to 7 https://docs.mql4.com/ru/customind/indicatorbuffers


thanks a lot :) the indicator is still not drawn, i got spikes in lines like price=iL[k]; where iL is my iLow...former Low

Anyway, I found out a lot of useful stuff...but I won't dig any further...

there is a simpler method to visualise the redrawing...without a custom indicator.

 
Roman.:

What does the textbook say here?

"

The parameters to be passed are indicated in parentheses after the name of the function to be called, and are listed separated by commas. The number of parameters passed to the function must not exceed 64. The function may also not use the passed parameters. In this case, an empty parameter list is indicated, i.e. opening and closing parentheses are placed immediately after the function name.

The number, type and order of the parameters passed in the function call must coincide with the number, type and order of formal parameters, specified in the function description (exception is the call of a function, which has default parameters - see Function call and Function description and return operator). If there is no such coincidence, the MetaEditor will output an error message. Constants, variables, expressions and arrays can be used as passed parameters. "

Read the textbook before writing, see underline, but failed to implement in practice - writes about incompatible type.
Reason: