Experts: 5_8 MACross - page 4

 
Shara1:

That is, I need after this line - int OnInit()

Insert this -

It will be like this-

Thank you.

Not quite like that. You need to compare the parameter "mafastperiod" and "maslowperiod".

 
Vladimir Karputov:

Not exactly. You need to compare the parameter "mafastperiod" and "maslowperiod".

So I only need to add one line? Like this:

//+------------------------------------------------------------------+

//| Expert initialisation function |

//+------------------------------------------------------------------+

int OnInit()

{

if(Inpmaslowperiod>=Inpmafastperiod)

{

 

OnInit() in which no cases where "fast" is greater than or equal to "slow" are allowed:

//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()
  {
   if(mafastperiod>=maslowperiod)
     {
      Print("\"MA fast: averaging period\" can not be greater and equal to \"MA slow: averaging period\"");
      return(INIT_PARAMETERS_INCORRECT);
     }
   SetMarginMode();
 
Vladimir Karputov:

OnInit() in which no cases where "fast" is greater than or equal to "slow" are allowed:

Thanks, it seems to work, the code compiled.


//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()
  {
   if(mafastperiod>=maslowperiod)
     {
      Print("\"MA fast: averaging period\" can not be greater and equal to \"MA slow: averaging period\"");
      return(INIT_PARAMETERS_INCORRECT);
     }
   SetMarginMode();
   SetMarginMode();

But these two lines are the same, is that how it should be?

 
Shara1:

Thanks it seems to work, the code compiled.


But these two lines are the same, should they be?

No. You copied an extra line. Take out one line.

 
Vladimir Karputov:

No. You copied the extra line. Take out one line.

Thank you very much. Is it possible to add this to any EA with two muves?

 
Shara1:

Thank you very much. So you can add it to any EA with two muves ?

Yes, the main thing is to write the variable names correctly.

 
Vladimir tester writes an error. Please see what my error is.
Files:
20180221.log  11 kb
 
Shara1:
Vladimir tester writes an error. Please see what my error is.

Everything is normal.

"incorrect input parameters" is just the code triggering

   if(mafastperiod>=maslowperiod)
     {
      Print("\"MA fast: averaging period\" can not be greater and equal to \"MA slow: averaging period\"");
      return(INIT_PARAMETERS_INCORRECT);
     }

in the process of genetic optimisation

 
Vladimir Karputov:

It's all right.

"incorrect input parameters" is just a code trigger.

during the genetic optimisation process.

Thanks, but in the optimisation window, some lines are red because of this ?