Features of the mql4 language, subtleties and techniques - page 3

 

When launching a script, an indicator, an Expert Advisor, the names of variables are displayed in the Input Parameters tab

extern int Период=10;


If the #property strict directive is present, the comment is displayed instead of the variable name

#property strict
extern int Период=10;  // Период отображения информации

This is more informative, IMHO

 
LRA:

When launching a script, an indicator, an Expert Advisor, the names of variables are displayed in the Input Parameters tab


If the #property strict directive is present, the comment is displayed instead of the variable name

IMHO, it is more informative.

Well, then especially for those who didn't know that. See the screenshot, everything is clear there.


 

There is a glitch in MT4: When the depo is greater than 999999, one digit is missing from the detailed report chart.

If it is over 999999, two digits are missing. Only the top 5 digits are always displayed.


 
LRA:

There is a glitch in MT4: When the depo is greater than 999999, one digit is missing from the detailed report chart.

If it is over 999999, two digits are missing. Only the top 5 digits are always displayed.


Don't forget to say that you have the font scale set to 125% in the system settings
 
void OnStart()
{
  Alert("Ордеров = ",OrdersHistoryTotal());
}   

Did you know that you can set the length of the story? This affects the time it takes to search!

If you set today - there will be less of everything! At midnight will the story be empty? Optimally - the last 3 days.

To the developers: how can you set the depth of history programmatically?

 
Unlike MQL5, in MQL4 static arrays can change size.
 
fxsaber:
Unlike MQL5, in MQL4 static arrays can change their size.

Is there an error in the help?

//+-------------------------------------------------------+
//| ArrayResize                                 PROBA.mq4 |
//+-------------------------------------------------------+
#property strict
void OnStart()
{
  int x[7];         int СтарыйРазмер=ArrayRange(x,0);
  ArrayResize(x,5); int МеньшийРазмер=ArrayRange(x,0);
  ArrayResize(x,9); int БольшийРазмер=ArrayRange(x,0);
  Alert("MQL4: СтарыйРазмер = ",СтарыйРазмер, "   МеньшийРазмер = ",МеньшийРазмер, "   БольшийРазмер = ",БольшийРазмер);
} 


//+-------------------------------------------------------+
//| ArrayResize                                 PROBA.mq5 |
//+-------------------------------------------------------+
#property strict
void OnStart()
{
  int x[7];         int СтарыйРазмер=ArrayRange(x,0);
  ArrayResize(x,5); int МеньшийРазмер=ArrayRange(x,0);
  ArrayResize(x,9); int БольшийРазмер=ArrayRange(x,0);
  Alert("MQL5: СтарыйРазмер = ",СтарыйРазмер, "   МеньшийРазмер = ",МеньшийРазмер, "   БольшийРазмер = ",БольшийРазмер);
}
 
LRA:

Is there an error in the certificate?

There is no error if you consider that there are no static arrays in MQL4.
 
On the subject of static, there is a subtle point in both languages

Forum on trading, automated trading systems and testing trading strategies

mt4 build 1066

James Cater, 2017.04.28 16:53

I have found a regression error with initialisation order of static variables within functions

This was working in build 1065. I have reported this to the service desk

#property strict
#property indicator_chart_window

int TestBrokenStatic()
{
   static int stInt = 101;
   
   stInt++;
   return stInt;
}

int OnInit()
{
   static int result = TestBrokenStatic();
   
   Print("TestStatic Expected result 102   - Actual result=", result);
   result = TestBrokenStatic();
   Print("TestStatic Expected result 103   - Actual result=", result);
   
   return INIT_SUCCEEDED;
}

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 rates_total;
}


2017.04.28 15:42:30.941 TestStatic EURCHF,H1: TestStatic Expected result 103 - Actual result=102

2017.04.28 15:42:30.941 TestStatic EURCHF,H1: TestStatic Expected result 102 - Actual result=1


 
fxsaber:
There's a subtle moment in both languages

What a subtle point... Did you write it in SD?