MQL5 MetaTrader 5용 소스 코드 라이브러리

icon

라이브러리는 특정 기능을 포함하는 작은 하위 프로그램으로, 새로운 응용 프로그램을 개발하는 데 사용될 수 있습니다. 일단 작성되고 철저히 점검되면, 사용자는 라이브러리를 통해 새로운 MQL5 응용 프로그램의 개발 속도를 높일 수 있습니다. 예시 중 하나는 여러 수치 분석 함수를 포함하는 ALGLIB 라이브러리입니다.

MetaEditor에서 거래전략 개발 시 라이브러리 소스 코드를 다운로드하여 사용할 수 있습니다. 그것들은 MetaTrader 5에서는 독립적으로 실행할 수 없습니다.

코드를 제출하세요

A stop distance in points is not money until the tick size and tick value make it one. This library turns four risk bases into a lot size, floors it to the volume step, caps it against free margin and tracks a daily loss limit. Two MQL5 headers, no DLL.

A one-file library that handles how an EA trades: pre-trade checks, normalisation to broker limits, safe retries, one order per signal, isolation by magic number and state recovery after a restart. Lot by risk, daily loss limit and equity floor included. Verified in the Strategy Tester.

Fits five bivariate copulas on ranks, with Kendall's tau, tail dependence, the probability of joint extreme days, AIC and the conditional probabilities of pairs trading.

Online detection of changes in the mean or volatility (Adams-MacKay): probability of a change in the last k bars, current segment length, forecast, and an indicator.

Exact maximum likelihood of an Ornstein-Uhlenbeck spread and Bertram's optimal entry and exit levels for a given cost, with the expected length of a trade cycle.

A lightweight tab bar for chart panels, drawn with the standard CCanvas class. One include file, several independent instances per chart, click selection, resizing and safe cleanup. Includes a demo Expert Advisor.

Parkinson, Garman-Klass, Rogers-Satchell and Yang-Zhang estimators, daily realized and bipower variance from intraday bars, and HAR volatility forecasts.

Five tests to tell a random walk from a mean-reverting series: KPSS, Phillips-Perron, DF-GLS, Zivot-Andrews with the break date, and the variance ratio.

Detects the broker's GMT offset and its daylight-time rule (fixed, US or European) from the weekly closes in the H1 history, the same way live and in the Strategy Tester, with functions that convert New York times to server time and back.

Is the best of many strategies really better than the benchmark? Hansen's SPA test, White's Reality Check, Romano-Wolf StepM and the model confidence set.

Unit root and cointegration tests (ADF, Engle-Granger, Johansen) with MacKinnon p-values, hedge ratio, half-life and z-score of the spread, and a pair scanner.

Kalman filter and smoother with an exact diffuse start, missing values and maximum likelihood: local level, local linear trend and a regression whose hedge ratio drifts.

Gaussian hidden Markov model fitted by Baum-Welch: regime probabilities without look-ahead, most likely path, expected durations and regime forecasts.

Holidays and early halts of the CME equity index futures (S&P 500, Nasdaq-100, Dow, Russell 2000, E-mini and Micro), computed from the US holiday rules for any year, with a script that checks the calendar against your broker's own M1 history.

Include for EAs running 24/7 on an MQL5 VPS or PC: run-where switch, order send with OK/FAIL/UNKNOWN result (no duplicate orders after a timeout), restart-safe counters, positions closed while the EA was off, append-only log and optional Telegram. No trading logic inside.

Fits GARCH(1,1), GJR-GARCH and EGARCH with normal, Student t or GED shocks by maximum likelihood, with robust standard errors and variance forecasts.

백테스트에서도 작동하는 진정한 경제 캘린더 뉴스 필터입니다. 스크립트를 통해 이벤트를 한 번만 내보내면, 실시간 환경과 전략 테스터 모두에서 뉴스 발생 시 새로운 진입을 차단할 수 있습니다. 과거 캘린더 시간의 1시간 일광절약시간제(DST) 변경 문제를 해결합니다.

Probability of Backtest Overfitting (PBO) of an MT5 optimization by combinatorially symmetric cross-validation. Every pass sends its daily results as a frame, and the PBO is computed when the optimization ends.

Block bootstrap of daily results: how deep the drawdown of an account or strategy can get over the next months, with percentiles and a seeded generator for repeatable runs.

Portfolio weights from the returns of symbols or Expert Advisors: inverse volatility, risk parity, hierarchical risk parity, minimum variance, maximum diversification, Ledoit-Wolf covariance.

Reads a Strategy Tester report saved as HTML into its deals, closed trades, net profit and balance drawdowns, for comparing, combining or exporting backtests.

Single-header account lock for MT5 EAs: licensed account numbers, optional demo allowance, expiry date, tester bypass. Licence compiled in with #define. No DLL.

EA의 모든 진입 유형에 대해 하나의 순자산 곡선에 묶어두지 않고 각각의 기록으로 점수를 매깁니다. 초기화 시 계좌의 거래 내역을 바탕으로 자체적으로 재구성되므로, 재시작하더라도 기록이 지워지지 않습니다. 원시 승률 옆에 윌슨 점수 하한값을 표시하여, 3회 연속 승리로 인한 호조세가 우위처럼 보이지 않도록 합니다.

AttachExpert.mqh attaches an Expert Advisor to a chart from MQL5 code, with the inputs you choose and with "Allow Algo Trading" on or off.

각기 다른 기능을 하는 세 가지 포지션 규모 조정 보호 기능; 이들을 혼동하는 것이 수많은 계좌가 전액 손실을 입는 주된 이유입니다: - 래더(ladder): 잔고의 X당 1계약으로, 수동 로트 조정 시에도 항상 상한선(CAP)으로 적용됩니다; - 플로어(floor): 최소 자본금 미만이면 거래가 중단되며, 새로운 입금이 필요합니다; - 브레이커(breaker): 계좌 규모와 관계없이 최고점 대비 X% 아래로 떨어지면 거래가 중단되며, 자동으로 재설정되지 않습니다. 이 라이브러리가 해결하는 문제이자, 다른 라이브러리들은 거의 다루지 않는 점: 입금은 이익이 아니며, 출금은 손실이 아닙니다. 브레이커는 잔고 최고치를 기준으로 하락폭을 측정합니다. 이를 처리하지 않으면, 드로우다운 중에 이루어진 입금은 잔고와 최고치를 동시에 끌어올리게 되며, 보호 기능은 도움이 될 바로 그 시점에 하락을 감지하지 못하게 됩니다. 이 경우 입금과 출금은 최고치를 동일한 만큼 이동시킵니다. 최고점은 파일에 저장됩니다. 터미널 재시작 시 최고점을 잊어버리는 브레이커는 진정한 브레이커가 아닙니다. 이 데모는 드로우다운 최저점에서 입금이 이루어지는 상황을 시뮬레이션합니다. 입금 기능을 켜고 끈 상태로 실행하여 “하락” 열을 비교해 보십시오.

위험 금액을 기준으로 한 포지션 규모는, 가정된 핍(pip) 값이 아닌 해당 종목의 실제 틱 값, 틱 크기 및 거래량 단위를 바탕으로 계산됩니다. 거래량은 항상 아래로 반올림되며, 위험 금액이 최소 랏보다 작을 경우 이를 알리고 해당 랏의 실제 비용을 보고합니다. 터미널 상태가 아니므로 포지션 크기 산정 로직을 오프라인에서 테스트할 수 있으며, 41개의 어설션으로 구성된 테스트 스크립트가 포함되어 있습니다.

Calculates the Strategy Tester report statistics from the deal history, including Z-Score, AHPR, GHPR, LR Correlation and LR Standard Error, which TesterStatistics() does not return. Checked value by value against the tester.

An include file that writes real Excel workbooks (.xlsx) from MQL5 without DLLs: several sheets, numbers, text and real Excel dates, a frozen bold header and filters. Example script: the account deals and the daily results to Excel.

A small include file that tells your Expert Advisor when it is inside a news window, using the economic calendar built into MetaTrader 5. No web requests and no DLL.

24개의 MQL5 클래스로 구성된 라이브러리로, 특정 계좌에 대해 프로프 펌의 규칙집(드로우다운, 일일 손실, 수익 지급 일관성, 최소 거래 일수, 뉴스 블랙아웃 등)을 모니터링하며, 규칙 위반 시 자체 포지션을 개설하지 않고 즉시 거래를 중단합니다.

The library reconstructs a complete MQL4-style order model on top of the native MQL5 Position, Order, Deal, and History APIs. This design allows legacy MQL4 Expert Advisors to operate with minimal code changes while preserving MQL5.

모든 금융 상품에 걸쳐 정확한 핍 값 계산과 동적 랏 크기 조정이 가능한, 가볍고 OOP를 준수하는 MQL5 헤더 클래스(.mqh)로, 자동 통화 간 환율 변환 및 브로커 거래량 정규화 기능을 갖추고 있습니다.

브로커가 어떤 명칭으로 부르든 상관없이 ‘골드’ 심볼을 감지하고, 계약 사양을 임의로 가정하지 않고 터미널에서 직접 읽어오며, 계좌 통화로 표시된 위험 금액을 해당 브로커에 맞는 정확한 랏 크기로 변환합니다.

Look after open positions in an Expert Advisor: break-even, trailing stop, two partial closes, and a stop and target for positions that have none. It never opens a trade.

A small include file for Expert Advisors and trade managers. It turns your risk rules into yes/no answers: how many lots does this stop allow, is the daily loss limit reached, is the maximum drawdown (static or trailing) reached, how much is at risk across all open positions, and are spread and session acceptable. The lot is never rounded up: if the broker minimum lot would risk more than allowed, the trade is skipped and the reason is returned. Limits survive a terminal restart. The library only measures: it sends no order. Includes a demo account guard (no trading by default) and a self-test with 78 checks.

Four EAs writing to the same file, all with FILE_SHARE_READ|FILE_SHARE_WRITE, FileSeek(SEEK_END), FileWrite, FileClose. Looks correct. Every FileOpen returns success. No error in the log. And the lines vanish. Reason: FILE_SHARE_WRITE lets all four open at the same time. All four call FileSeek(SEEK_END) and get THE SAME offset, because none has written yet. All four write at the same position. Whoever closes last wins. Three lines vanish silently. In my case: 12 events expected, 8 in the file. The fix is to open EXCLUSIVELY (no FILE_SHARE_WRITE) and retry while another EA holds the file. And to shout in the log when the retries run out: a log that fails silently is worse than no log at all, because you trust it. The demo script reproduces both modes. To see the loss, drag it onto four charts at the same time with safe mode off and count the lines in the CSV. On a single chart the defect does not show up - which is why it passes in testing and breaks in production.

A daily process writes "today's decision" (which strategy runs, or FLAT) to a file the EAs read at the open. One day the writer did not run. The EAs read yesterday's file, compared its date with TimeCurrent() - the server clock, which had stepped back to the previous day overnight - saw a match, and traded all morning on a 24-hour-old decision. No error anywhere. Two rules, both in this class: 1) staleness is judged against TimeLocal(), which always moves forward; TimeCurrent() is the last tick's stamp - it freezes without ticks and can step back on reconnect. 2) When in doubt the answer is FLAT: missing file, bad date, wrong day, empty line - every failure path returns "do nothing", and each is logged ONCE per state change, not on every tick and not never. File format: line 1 = ISO date, line 2 = decision string. The demo writes a fresh, a stale, a malformed, an empty and a missing file, and shows that only the first is allowed to trade.

Four EAs on the same symbol, each one honest on its own: each checks "do I have a position?" with its own magic number, sees none, and enters. On a demo account this reached 22 contracts on a symbol meant to carry 1, and a watchdog had to close 16 positions in one morning. The cap belongs at the door, not after the fact. ExposureCap::Allowed(symbol, lots, cap) sums the volume of every open position on the symbol - all magic numbers, manual trades included - and refuses the order BEFORE it is sent when it would breach the cap. One log line with the three numbers (held, requested, cap) says why. Deliberately simple: gross exposure, no netting of longs against shorts, no per-EA quota. It is a check, not a lock: two EAs deciding on the same tick can both pass; in practice EAs on different charts decide on different ticks. The demo script prints held / cap / room for the current symbol and shows the refusal line. Nothing is traded.

채널 기반 지표에 대한 근접 신호를 가져오는 라이브러리

MQL5에 Rust 스타일의 Result 타입을 도입하는, 크기가 작고 의존성이 적은 라이브러리입니다. 함수는 전역 GetLastError() 상태에 의존하는 대신 단일 값 또는 오류 객체를 반환하므로, 오류가 명확하게 드러나 무시할 수 없습니다. 이 라이브러리에는 ResultValue(값형) 및 Result(포인터로 참조되는 객체), Error 구조체, 조기 반환 매크로(TRY, RETURN_ON_ERROR 등)와 선택적 Then/Match/MapError 콜백이 포함되어 있습니다.