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

Broker Clock - MetaTrader 5용 라이브러리

Hayk Babayan
Hayk Babayan
Algorithmic trader. I build and test Expert Advisors for MetaTrader 5 with one rule: a strategy has to prove itself on data it has never seen before I trust it.
조회수:
44
평가:
(1)
게시됨:
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

An EA that trades at "08:00 London" or "09:30 New York" has to turn that into broker server time, and the answer changes during the year. Most brokers run their server at UTC+2 in winter and UTC+3 in summer, switching on the US dates. Europe switches two to three weeks later in spring and one week earlier in autumn, so for about a month a year a fixed server hour points at the wrong market hour. In the Strategy Tester it is worse: TimeGMT() simply follows the server clock, so the offset cannot be measured at all.

BrokerClock.mqh is one include file with the rules built in. It works on any date, so backtests over many years use the right offset for every single day.

BrokerClockPanel example indicator

What it does

  • Daylight saving rules for the US, the EU (London, Frankfurt) and Sydney; Tokyo has none.
  • Three common broker server clocks: UTC+2/+3 on US dates ("New York close", the most common), UTC+2/+3 on EU dates, and UTC+0/+1 (London). A fixed offset is also possible.
  • Live, the rule can be detected from the current server offset (SERVER_AUTO). In the tester, set it explicitly.
  • Conversions between server time, UTC and market local time in every direction.
  • ZoneTimeOnServer(): "08:00 London today" as server time, in one call.
  • Tested every hour from 2015 to 2030 against the IANA time zone database: no differences.

Example

#include "BrokerClock.mqh"
CBrokerClock clock;

int OnInit()
  {
   clock.Init(SERVER_NY_CLOSE);          // or SERVER_AUTO on a live account
   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
   datetime now =TimeCurrent();
   datetime open=clock.ZoneTimeOnServer(now,CLOCK_LONDON,8,0);   // today's 08:00 London, in server time
   if(now>=open && now<open+60)
      Print("London is opening");
  }

Example indicator

BrokerClockPanel shows the server time, UTC and the five markets with their current zone (GMT/BST, EST/EDT, ...), and the server time of any market hour you choose. Put BrokerClock.mqh in the same folder as the indicator.

Notes

  • The US rule is the one used since 2007, and Sydney's since 2008. Dates before that are not covered.
  • In autumn one clock hour happens twice. For that hour the conversions return the earlier moment.
  • In SERVER_AUTO mode the offset is measured from your PC clock (TimeGMT), so keep the PC clock synchronised.
Market Structure Visualizer - HH HL LH LL BOS CHoCH Market Structure Visualizer - HH HL LH LL BOS CHoCH

Free non-repainting MT5 market structure indicator that identifies confirmed HH, HL, LH and LL swings, plots BOS and CHoCH structure breaks, and includes close/wick confirmation, dashboard bias and optional alerts.

Risk Lot Calculator Risk Lot Calculator

Drop it on the chart at your stop-loss level and get the exact lot for your risk. Correct for gold, indices, crypto and cross pairs. It never opens trades.

Dashboard Panel Dashboard Panel

A clean information card for your EA or indicator: rows, progress bars and a status pill on one anti-aliased CCanvas bitmap, light or dark to match the chart, and foldable with a click.

LotFromRisk: position size from risk, stop and commission LotFromRisk: position size from risk, stop and commission

An include file for calculating the size of a position to be opened. It turns a risk figure (percent of the balance, percent of the equity or money), a stop and a commission per lot into a lot size whose loss at the stop never goes over that risk. The lot is always rounded down to the volume step and a risk below the minimum volume returns 0 lots with a reason.