Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Time since January 1, 1970 in microseconds (µs) - MetaTrader 5 Library

author EAcpu | 3 reads | 0 comments |

Time in microseconds (µs) since 01/01/1970 - library for MetaTrader 5

Simple class for getting the number of microseconds (μs) that have elapsed since January 1, 1970.
The error of this method is about 0.5 milliseconds. This is due to the discrete time nature of updating the TimeLocal() function.

At the beginning of your program (script, indicator or advisor) you need to create an instance of this class:

 #include

C time μs t;

There are three methods in this class whose names describe their purpose:

 Oolong gets the local time(); Oolong gets the time trading server(); Oolong gets the Greenwich Mean Time();

A test script demonstrating such work is provided:

 #include C time μs t;

blank start () {
Although (! stop ()) {
comment ( "local-" + string ( t.GetTimeLocal() ) +
" µs\nGMT - " + string ( t.GetTimeGMT() ) +
"µs\nServer-" + string ( t.GetTimeTradeServer() ) + "microseconds" );
  }
Comment ( "" );
} //+------------------------------------------------------------------+

Time in microseconds (µs) since 01/01/1970 - library for MetaTrader 5


Attachment download

📎 timeus.mqh (2.61 KB)

📎 test_timeus.mq5 (1.7 KB)

Source: MQL5 #35815

Verification code Refresh