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

 
Igor Makanu:

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

To be used purely visually and informatively

 
Carcass77:

To be used purely for visual and informational purposes

//+------------------------------------------------------------------+
//|                                                    atrValues.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern int atrPeriod=10;
extern int infoCorner=0;
extern int shift=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   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);
//--- 
  }
//+------------------------------------------------------------------+
 
Alekseu Fedotov:

Lots of mistakes popped up)

 
Carcass77:

Lots of errors)

It compiles fine for me.

 
Alekseu Fedotov:

It compiles fine for me.

Found my mistake. Thank you very much!

 
How can I call any of the T1 object's methods inside a template-class with objects of non-explicit type (i.e. the object type is not set explicitly, but via template<typename T1>)? All T1 objects have identical methods.
 
Igor Makanu:

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

It says:
(highlighted in black).

INIT_PARAMETERS_INCORRECT

This is intended for indicating an incorrect set of input parameters by the programmer. The result string containing this return code will be highlighted in red in the general optimization table.

Testing will not be performed for this Expert Advisor's parameter set.


And here is the general optimization table:




Nothing is highlighted in red.

It's just that in such lines the optimization result is zero.


Does the manual lie or am I doing something wrong?

 
Is there any way to display the keys in the input so that they can be reassigned?
 
Roman Sharanov:
Is there any way to get the keys into the input so that they can be reassigned?

Can.

#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//--- input parameters

input string      key = "A";

//+------------------------------------------------------------------+
//| 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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {

   if(id==CHARTEVENT_KEYDOWN)
     {
      if(lparam==(StringGetChar(key,0)))
        {
        Alert("нажатая клавиша = ",key);
        Alert("код нажатой клавиши = ",StringGetChar(key,0));
        }
     }
  }
//+------------------------------------------------------------------+
 
multiplicator:

Here it says:
(highlighted in black).

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 Expert Advisor's parameter set.


And here is the general optimization table:




Nothing is highlighted in red.

It's just that in such lines the result of optimization is zero.


Does the manual lie or am I doing something wrong?

Now you can see that nothing is highlighted and contradicts the manual in this regard.