Features of the mql5 language, subtleties and tricks - page 194

 

Hello, help from the experts!

From documentation

Global variables

"Initialization of global variables is performed once after the program is loaded into the client terminal's memory and before the first Init event is handled. For global variables, which are objects of classes, during initialization the appropriate constructors are called."

But in fact, when I change period of chart, the constructor of global object class in indicator is called.

How to make the constructor be called once after indicator start?

 
Gudgeon:

But in fact, when I change the chart period, the constructor of the object class in the indicator is called.

How to make the constructor be called once after the indicator is started?

Change of TF for the indicator - start of a new copy of the program.

 
fxsaber:

Changing the TF for the indicator - running a new copy of the programme.

Thank you!

Unexpectedly, I don't understand from the documentation.

Everything is OK in Expert Advisors.

 
You can find out how long it takes to compile your programme as follows.
LastModifyEX5() - __DATETIME__
 
fxsaber:
You can find out how long it takes to compile your program as follows.
What is LastModifyEX5()? I can't find it on the website.
 
Alexey Viktorov:
And this LastModifyEX5() what? I can't find it on the website.

You have to write this yourself through the WinAPI. The implementation is secondary here.

 

My friends, fellow hobbyists!

How can I programmatically set visibility for a specific indicator on a specific TF,

Considering that there may be another 5 indicators for other TFs.

I searched in the description, and very simply, the search in the help, but the search of the description gives no result on the mechanism to solve it.


I know how to set object visibility.

 
The limiter can change itsORDER_TIME_SETUP_MSC - in case of partial execution this property becomes equal to the time of the first (possibly penultimate) partial execution.
 
In the Tester, this condition will always be triggered.
int OnInit()
{
  MqlTick Tick;
  
  return(SymbolInfoTick(_Symbol, Tick) && (TimeCurrent() != Tick.time));
}
It is hard to tell if this is a bug in the tester or a feature.
 

A way of determining the GMT offset of the server time wasonce proposed. It does not always work accurately.

Below seems to be an accurate version.

// Аналог по серверному времени - https://www.mql5.com/ru/docs/dateandtime/timegmtoffset
int TimeServerGMTOffset( void )
{
  MqlCalendarValue Value[1];
  
  CalendarValueHistoryByEvent(840030016, Value, D'2020.12.03', D'2020.12.06');
  
  return((13 - ((Value[0].time / 3600) % 24)) * 3600);
}

// Аналог по серверному времени - https://www.mql5.com/ru/docs/dateandtime/timegmt
datetime TimeServerGMT( void )
{
  return(TimeTradeServer() + TimeServerGMTOffset());
}


Forum on trading, automated trading systems and trading strategies testing

Features of mql4 language, intricacies and tricks

fxsaber, 2018.03.29 14:32

Applications

#define  PRINT(A) Print(#A + " = " + (string)(A))

void OnStart()
{  
  PRINT(TimeGMT());
  PRINT(TimeServerGMT());  
}
Reason: