당사 팬 페이지에 가입하십시오
- 조회수:
- 72
- 게시됨:
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
Purpose
This include file provides a value-or-error return type for MQL5, so functions can report success or failure explicitly instead of through the global GetLastError() / ResetLastError() state — which is easy to forget, easy to overwrite, and forces out-parameters and "magic" return values.
What it does
A function returns one object that either holds a value or an Error; the caller must check before using the value.
- ResultValue<T> — for value types (numbers, structs).
- Result<T> — the same contract for objects held by pointer (classes).
- Error — a lightweight struct (code + description); codes map to readable names via EnumToString.
- MQLError — a thin wrapper over GetLastError / ResetLastError / SetUserError.
- Macros — TRY , RETURN_ON_ERROR , PRINT_ON_ERROR , RETURN_SAME_ON_ERROR , RESULT_ON_ERROR — for early-return propagation without boilerplate.
- Optional callbacks — Then , Match , MapError (they take top-level or static functions; MQL5 has no closures).
Accessors: Value() , ValueOr(fallback) , CurrentError() , IsError() .
Usage
// Stage functions (top-level — MQL5 has no closures) ResultValue<double> EnsurePositive(const double &value) { if (value <= 0.0) { return ResultValue<double>::Fail("price must be positive"); } return ResultValue<double>::Ok(value); } ResultValue<double> ToPips(const double &price) { return ResultValue<double>::Ok(price / _Point); } Error Describe(const Error &error) { return Error::Create(error.code, "pipeline failed: " + error.description); } void OnOk(const double &value) { PrintFormat("[pipeline] result = %.1f pips", value); } void OnFail(const Error &error) { PrintFormat("[pipeline] %s", error.description); } // The pipeline: read -> validate -> transform -> (annotate error) -> handle void RunPipeline() { SymbolDouble("EURUSD", SYMBOL_BID) .Then(EnsurePositive) .Then(ToPips) .MapError(Describe) .Match(OnOk, OnFail); }
Pip Value Calculator
Live pip value, risk-based lot sizing, custom volume risk analysis & open position P/L — all in one panel.
ATR Ranked Support and Resistance Zones
An educational MT5 indicator that builds support and resistance as price zones from confirmed pivots. Nearby reactions are merged using ATR-based distance, then ranked by repeated tests, rejection strength and recency. Only the strongest zones are displayed to keep the chart readable.
Accelerator Oscillator (AC)
The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.
MACD Signals
Indicator edition for new platform.
