거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

AccurateTimer - MetaTrader 5용 라이브러리

조회수:
4405
평가:
(25)
게시됨:
2018.03.01 11:34
\MQL5\Experts\fxsaber\AccurateTimer\ \MQL5\Include\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

The MetaTrader 4/5 standard timer is based on the system timer call and can therefore work inaccurately. We can check this by running the following simple Expert Advisor:

input int Timer = 1000; // The number of milliseconds for the timer to trigger

#define TOSTRING(A) #A + " = " + (string)(A) + " ms.\n"

const bool Init = EventSetMillisecondTimer(Timer);

// Shows the current timer error and its average value as a comment on a chart
void OnTimer()
{
  static ulong StartTime = 0;
  static int Count = 0;
  static int Sum = 0;

  if (StartTime)
  {
    const int RunTime = (int)(GetMicrosecondCount() - StartTime) / 1000;
    const int Error = RunTime - Timer * Count;

    Sum += Error;

    Comment(TOSTRING(Timer) + TimeToString(RunTime / 1000, TIME_SECONDS) + "\n" +
            TOSTRING(Error) + TOSTRING((double)Sum / Count));
  }
  else
    StartTime = GetMicrosecondCount();

  Count++;
}

In the chart comment (the upper left corner) it shows how the timer lag grows:

The screenshot shows that in just a minute, the second timer creates a lag of more than a second. Moreover this lag grows over time!

This library allows increasing the accuracy of the standard timer for any Expert Advisor/indicator. For this purpose, the following line should be added at the beginning of the code:

#include <AccurateTimer.mqh> // Increasing the accuracy of the standard timer

After that the following comment will be shown:

After ten minutes of operation, the average deviation from the ideal (theoretical) timer is ~1 ms, and the error will not grow.

It is always good to have an accurate timer. But for some tasks it is a must. For example, a second timer synchronized with the trade server time.

This cross-platform library is compatible with all Expert Advisors/indicators, which use the standard timer (OnTimer). It does not affect the execution speed in the strategy tester.

Increase the accuracy of your existing and new programs in just one line!

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/19859

ZScore ZScore

The ZScore indicator shows relative price deviation from its average value.

RSI on the Price Chart RSI on the Price Chart

Standard RSI on the price chart.

Custom Moving Average Input Color Custom Moving Average Input Color

A modification of the "Custom Moving Average" indicator: now the line color can be passed in input parameters.

MA with Band MA with Band

The indicator displays a Moving Average with bullish and bearish areas.