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

 
multiplicator:

INIT_PARAMETERS_INCORRECT

Designed to indicate an incorrect set of input parameters to the programmer, the result string with this return code will be highlighted in red in the general optimization table.

Testing will not be performed for this set of Expert Advisor parameters.



Something is not highlighted in red.

Is it so for everyone?


here is the code in oninit:


The journal generates the following errors:



Is it strange that it writes like this?

You specifically in onInit() return INIT_PARAMETERS_INCORRECT

What you wrote in your code is what you get in the terminal/tester; if you return INIT_FAILED, it means wrong initialization and no testing ... so what you wrote, you get, so what is the question?

 
multiplicator:

INIT_PARAMETERS_INCORRECT

Designed to indicate an incorrect set of input parameters to the programmer, the result string with this return code will be highlighted in red in the general optimization table.

Testing will not be performed for this set of Expert Advisor parameters.



Something is not highlighted in red.

Is it so for everyone?


this is the code in OnInit:


The journal generates errors like these:



Where is the optimization table itself that would show what you are asking about?

 
Igor Makanu:

is it strange that it writes like this?

You specifically in onInit() and return INIT_PARAMETERS_INCORRECT

What you wrote in the code is what you get in the terminal/tester; if you return INIT_FAILED, it means wrong initialization and no testing... what you wrote is what you got, so what's the question?

the question is not highlighting red. )
 
multiplicator:
question is not highlighting red. )

I understand, I don't have a terminal handy, but it seems that only error logs in the meta-editor are highlighted in red, while in the terminal and in the tester only the icon is red, and the text itself does not seem to "redden"

 
Igor Makanu:

I see, I don't have a terminal handy, but it seems that only the error logs in the meta-editor are highlighted in red, while in the terminal and in the tester only the icon is red, and the text itself does not seem to "redden"

I've never gone red, neither from embarrassment, nor from stress.

 
Good afternoon. Please help me to put the indicator into my EA. Which sections should I copy it to?
//+------------------------------------------------------------------+
//|                                                    atrValues.mq4 |
//|                                    Copyright 2015, Mohit Marwaha |
//|                                                marwaha1@gmail.com|
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Mohit Marwaha"
#property link      "marwaha1@gmail.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//---
extern int atrPeriod=10;
extern int infoCorner=0;
extern int shift=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("Copyright MohitMarwaha");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectsDeleteAll();
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   double atr1=iATR(Symbol(),1,atrPeriod,shift);
   double atr5=iATR(Symbol(),5,atrPeriod,shift);
   double atr15=iATR(Symbol(),15,atrPeriod,shift);
   double atr30=iATR(Symbol(),30,atrPeriod,shift);
   double atr60=iATR(Symbol(),60,atrPeriod,shift);
   double atr240=iATR(Symbol(),240,atrPeriod,shift);
   double atr1440=iATR(Symbol(),1440,atrPeriod,shift);
   double atr10080=iATR(Symbol(),10080,atrPeriod,shift);
   double atr43200=iATR(Symbol(),43200,atrPeriod,shift);
//---
   ObjectCreate("ObjName1",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName1","ATR"+IntegerToString(atrPeriod,0)+": M1="+DoubleToStr(atr1,5),8,"Verdana",Red);
   ObjectSet("ObjName1",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName1",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName1",OBJPROP_YDISTANCE,25);
//---
   ObjectCreate("ObjName2",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName2","ATR"+IntegerToString(atrPeriod,0)+": M5="+DoubleToStr(atr5,5),8,"Verdana",Red);
   ObjectSet("ObjName2",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName2",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName2",OBJPROP_YDISTANCE,40);
//---
   ObjectCreate("ObjName3",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName3","ATR"+IntegerToString(atrPeriod,0)+": M15="+DoubleToStr(atr15,5),8,"Verdana",Red);
   ObjectSet("ObjName3",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName3",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName3",OBJPROP_YDISTANCE,55);
//---
   ObjectCreate("ObjName4",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName4","ATR"+IntegerToString(atrPeriod,0)+": M30="+DoubleToStr(atr30,5),8,"Verdana",Red);
   ObjectSet("ObjName4",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName4",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName4",OBJPROP_YDISTANCE,70);
//---
   ObjectCreate("ObjName5",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName5","ATR"+IntegerToString(atrPeriod,0)+": M60="+DoubleToStr(atr60,5),8,"Verdana",Red);
   ObjectSet("ObjName5",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName5",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName5",OBJPROP_YDISTANCE,85);
//---
   ObjectCreate("ObjName6",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName6","ATR"+IntegerToString(atrPeriod,0)+": M240="+DoubleToStr(atr240,5),8,"Verdana",Red);
   ObjectSet("ObjName6",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName6",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName6",OBJPROP_YDISTANCE,100);
//---
   ObjectCreate("ObjName7",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName7","ATR"+IntegerToString(atrPeriod,0)+": M1440="+DoubleToStr(atr1440,5),8,"Verdana",Red);
   ObjectSet("ObjName7",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName7",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName7",OBJPROP_YDISTANCE,115);
//---
   ObjectCreate("ObjName8",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName8","ATR"+IntegerToString(atrPeriod,0)+": M10080="+DoubleToStr(atr10080,5),8,"Verdana",Red);
   ObjectSet("ObjName8",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName8",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName8",OBJPROP_YDISTANCE,130);
//---
   ObjectCreate("ObjName9",OBJ_LABEL,0,0,0);
   ObjectSetText("ObjName9","ATR"+IntegerToString(atrPeriod,0)+": M43200="+DoubleToStr(atr43200,5),8,"Verdana",Red);
   ObjectSet("ObjName9",OBJPROP_CORNER,infoCorner);
   ObjectSet("ObjName9",OBJPROP_XDISTANCE,10);
   ObjectSet("ObjName9",OBJPROP_YDISTANCE,145);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Carcass77:
Good day. Please help me to put the indicator in my EA. Where do I copy it?

void OnTick()

 
Alekseu Fedotov:

void OnTick()

Tried

no indicator window property is defined, indicator_chart_window is applied 0 0


 
Carcass77:
Good day. Help to put the indicator in the EA. Which sections should I copy it to?

copying does not help, you need to read, here is the articlehttps://www.mql5.com/ru/articles/1456

Перенос кода индикатора в код эксперта. Строение индикатора.
Перенос кода индикатора в код эксперта. Строение индикатора.
  • www.mql5.com
Предполагается, что читатель знаком с оптимизацией кода индикатора для того, чтобы этот индикатор пересчитывался на новых тиках только на непосчитанных барах. На мой взгляд, начинать изучение программирования на языке MQL4 следовало бы именно с этих вещей. Если вы всерьёз собрались использовать своего эксперта в реальной торговле и доверять...
 
Igor Makanu:

copying won't help, you need to read, here's the articlehttps://www.mql5.com/ru/articles/1456

Ok, thank you.

Reason: