MQL5Book/Scripts/p4/TimeCount.mq5

27 lines
1 KiB
MQL5
Raw Permalink Normal View History

2025-05-30 16:09:41 +02:00
//+------------------------------------------------------------------+
//| TimeCount.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include "..\..\Include\PRTF.mqh"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
const uint startMs = GetTickCount();
const ulong startMcs = GetMicrosecondCount();
// loop for 5 seconds
while(PRTF(GetTickCount()) < startMs + 5000)
{
PRTF(GetMicrosecondCount());
Sleep(1000);
}
PRTF(GetTickCount() - startMs);
PRTF(GetMicrosecondCount() - startMcs);
}
//+------------------------------------------------------------------+