ARV EA Toolkit

  • 라이브러리
  • Roman Amirov
    Roman Amirov
    I’ve been trading Forex for over 5 years. During this time, I’ve tested a lot of third‑party EAs and realized a simple thing: if you want something done right, do it yourself! That’s why, instead of endlessly searching for the “perfect” ready‑made solution, I started turning my own trading ideas
  • 버전: 1.0
  • 활성화: 5
A dependency-free MQL5 library of independent building blocks for
Expert Advisor developers: risk-based position sizing, stop
construction, spread filter, logging, state persistence and a
retry state machine. No strategy, no profit claims.

---

ARV EA Toolkit is a dependency-free library of independent
modules for MQL5 Expert Advisor developers. Use only what you need;
the modules do not depend on each other except for a tiny shared
defines header. It contains no trading strategy and makes no
performance claims - it is correct plumbing for YOUR own logic.

Why it exists
  Most EA bugs are not in the signal - they are in the plumbing:
  wrong lot math, stops below the broker minimum, stacking positions,
  ignoring spread, lost state on reload, fragile close logic. This
  library gives you tested building blocks for exactly those tasks.

Modules (grouped by area)

  RISK & EXECUTION
    * ARV_RiskSizer.mqh    (CARVRiskSizer)   lot from risk %, money-at-risk.
    * ARV_StopBuilder.mqh  (CARVStopBuilder) build/validate SL/TP, broker min distance.
    * ARV_SpreadFilter.mqh (CARVSpreadFilter) current spread vs limit.
    * ARV_RiskToolkit.mqh  (CARVRiskToolkit) facade over the three above + position guards.
    * ARV_CloseRetry.mqh   (CARVCloseRetry, IARVRetryableOperation) exponential-backoff
                                             retry + escalation for close/order ops.

  DIAGNOSTICS & STATE
    * Logger.mqh           (CARVLogger)      4-level console/CSV logger.
    * ARV_Diagnostic.mqh   (CARVDiagnostic)  typed CSV streams (bar snapshot + events).
    * StateStore.mqh       (CARVStateStore)  key/value persistence over GlobalVariable
                                             + owner heartbeat (single-instance guard).

  MARKET UTILITIES
    * ARV_SymbolUtils.mqh  (CARVSymbolUtils) cached symbol specs + price/volume normalize.
    * ARV_TimeUtils.mqh    (CARVTimeUtils)   sessions (GMT), weekend window, new-bar, cooldown.
    * RegimeGate.mqh       (CARVRegimeGate)  ATR + SMA-drift + sigma/mu + cooldown filter.

  CORE (shared)
    * ARV_Defines.mqh      log levels, result codes, prefixes, heartbeat.

Included examples (MQL5\Experts\ARV\)
  * RiskToolkitDemo.mq5  - risk sizing, ATR stop, spread filter, single-position guard.
  * ARV_MinimalGrid.mq5  - Logger + StateStore + RiskToolkit + TimeUtils (fixed lot, equity stop).
  * ARV_Momentum.mq5     - RegimeGate + TimeUtils + RiskToolkit + CloseRetry + Diagnostic.
  (examples are API usage demos, NOT strategies)

Quick example
  #include <ARV\ARV_RiskToolkit.mqh>

  CARVRiskToolkit risk;
  risk.Init(_Symbol, 30);                       // spread limit, points
  double lot = risk.LotForRisk(_Symbol, 1.0, atr * 2.0);
  double sl, tp;
  risk.BuildStops(_Symbol, +1, ask, atr * 2.0, atr * 4.0, sl, tp);
  if(!CARVRiskToolkit::HasPosition(_Symbol, InpMagic) && risk.SpreadOK())
     trade.Buy(lot, _Symbol, 0.0, sl, tp, "comment");

API reference (public surface; abbreviated signatures, full declarations in headers)

Enumerations:
  enum ENUM_LOG_LEVEL;   // LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG
  enum ENUM_ARV_RESULT;  // ARV_OK, ARV_ERR_PARAM, ARV_ERR_INIT, ARV_ERR_IO, ARV_ERR_MARGIN, ARV_ERR_DUPLICATE

Classes:
  CARVLogger; CARVStateStore; CARVRegimeGate;
  CARVSymbolUtils; CARVRiskSizer; CARVStopBuilder; CARVSpreadFilter;
  CARVRiskToolkit; CARVTimeUtils; CARVCloseRetry; CARVDiagnostic;
  IARVRetryableOperation;  struct ARVBarSnapshot;

Key functions:
  // Risk & execution
  static double CARVRiskSizer::ForPercentRisk(string symbol, double equity, double riskPct, double slDistance);
  static double CARVRiskSizer::ForFixedLot(string symbol, double lot);
  static double CARVRiskSizer::LossPerLot(string symbol, double slDistance);
  static double CARVStopBuilder::MinDistance(string symbol);
  static bool   CARVStopBuilder::BuildStops(string symbol, int dir, double entry, double slDistance, double tpDistance, double &sl, double &tp);
  static bool   CARVStopBuilder::BuildATRStop(string symbol, int dir, double entry, double atr, double mult, double &sl);
  static bool   CARVStopBuilder::ValidateStop(string symbol, double entry, double stop, int dir);
  bool          CARVSpreadFilter::IsSpreadOK() const;
  int           CARVSpreadFilter::CurrentSpread() const;
  // Facade + position guards
  void          CARVRiskToolkit::Init(string symbol, int maxSpreadPoints = 0);
  double        CARVRiskToolkit::LotForRisk(string symbol, double riskPct, double slDistance) const;
  double        CARVRiskToolkit::LotFixed(string symbol, double lot) const;
  bool          CARVRiskToolkit::BuildStops(string symbol, int dir, double entry, double slDistance, double tpDistance, double &sl, double &tp) const;
  bool          CARVRiskToolkit::StopsDistanceOk(string symbol, int dir, double entry, double sl, double tp) const;
  static int    CARVRiskToolkit::CountPositions(string symbol, long magic);
  static bool   CARVRiskToolkit::HasPosition(string symbol, long magic);
  // Symbol specs & normalization (singleton)
  static CARVSymbolUtils *CARVSymbolUtils::Instance(string symbol = "");
  double        CARVSymbolUtils::NormalizePrice(double price) const;
  double        CARVSymbolUtils::NormalizeLot(double lot) const;
  bool          CARVSymbolUtils::ValidateLot(double lot) const;
  // Time & sessions (static)
  static datetime CARVTimeUtils::ToGMT(datetime serverTime = 0);
  static int      CARVTimeUtils::GMTHour(datetime serverTime = 0);
  static bool     CARVTimeUtils::IsAsianSession(datetime serverTime = 0);
  static bool     CARVTimeUtils::IsLondonSession(datetime serverTime = 0);
  static bool     CARVTimeUtils::IsNewYorkSession(datetime serverTime = 0);
  static bool     CARVTimeUtils::IsLondonNewYorkOverlap(datetime serverTime = 0);
  static string   CARVTimeUtils::SessionName(datetime serverTime = 0);
  static bool     CARVTimeUtils::IsWeekendWindow(int friCloseHour, int monResumeHour, datetime serverTime = 0);
  static bool     CARVTimeUtils::IsNewBar(string symbol, ENUM_TIMEFRAMES tf, datetime &lastBarTime);
  static bool     CARVTimeUtils::CooldownElapsed(datetime &lastEvent, int seconds);
  static int      CARVTimeUtils::SecondsUntilGMTHour(int gmtHour);
  // Logging
  void CARVLogger::Init(string tag = ARV_LOG_DEFAULT_PREFIX, ENUM_LOG_LEVEL minLevel = LOG_INFO, bool console = true);
  bool CARVLogger::EnableCsv(string fileName, string header = "time,level,tag,message");
  void CARVLogger::Log(ENUM_LOG_LEVEL level, string message, string tag = "");
  void CARVLogger::Error(string message, string tag = "");
  void CARVLogger::Warning(string message, string tag = "");
  void CARVLogger::Info(string message, string tag = "");
  void CARVLogger::Debug(string message, string tag = "");
  void CARVLogger::Shutdown();
  // State persistence + single-instance guard
  void          CARVStateStore::Init(string nameSpace);
  static string CARVStateStore::MakeNamespace(long login, string symbol, long magic);
  void          CARVStateStore::SetDouble(string name, double value);
  double        CARVStateStore::GetDouble(string name, double def = 0.0) const;
  void          CARVStateStore::MarkAlive();
  bool          CARVStateStore::IsAlive(int maxAgeSec = ARV_INSTANCE_HEARTBEAT_SEC) const;
  // Regime gate
  bool   CARVRegimeGate::Init(string symbol, ENUM_TIMEFRAMES tf, int atrPeriod, int maPeriod, int cooldownBars, string tag);
  bool   CARVRegimeGate::IsFavorable(double referenceDistance, double minRatio, double maxRatio, double minSigmaMu, bool requireTrend);
  double CARVRegimeGate::ATR();
  // Retry state machine
  bool CARVCloseRetry::Run(IARVRetryableOperation *op, CARVLogger *log, bool &outEscalated);
  bool CARVCloseRetry::Run(IARVRetryableOperation *op, CARVLogger *log = NULL);
  // Diagnostics (CSV)
  void CARVDiagnostic::Init(string prefix, string symbol = "", bool immediateFlush = true);
  void CARVDiagnostic::Bar(const ARVBarSnapshot &snap);
  void CARVDiagnostic::Event(string type, string key1, double val1, string key2, double val2);

Who it is for
  * MQL5 developers who want reliable risk/plumbing without re-writing it.
  * Sellers/students who want a clean reference implementation.

Requirements / compatibility
  * MetaTrader 5, current MQL5 build. Standard includes only.
  * No DLLs, no network, no third-party libraries.
  * Full source (.mqh) included; examples use <Trade\Trade.mqh> only.

What it is NOT
  * NOT an Expert Advisor and NOT a trading strategy.
  * No signal, no edge, and NO profit promise.
  * Example EA results are illustrative only.

Updates & support
  * Version 1.00. Bug reports and feature requests via product messages.
    Planned: minor helper additions only.

제작자의 제품 더 보기
RA Mean Reversion Portfolio RA Mean Reversion Portfolio는 MetaTrader 5용 멀티 커런시 EA입니다. 두 통화쌍에서 통계적으로 과도하게 벌어진 일봉 움직임을 찾아내고, 그러한 움직임이 최근 평균으로 되돌아가는 경향이 있다는 가정으로 거래합니다. 두 통화쌍은 하나의 차트에서 거래되며 하나의 리스크 한도로 하나의 포트폴리오 처럼 관리됩니다. 모든 거래에는 보호용 손절매가 설정됩니다. 전략 유형: D1 멀티 커런시 포트폴리오 평균 회귀(설계상 역추세). 이 EA는 D1에서만 작동하고, 심볼당 하나의 포지션만 보유하며, 그리드·물타기·마틴게일을 사용하지 않습니다. 장점 - 단순하고 완전히 결정론적인 로직. 신호는 일봉 종가의 z 점수이므로 모든 판단을 사용자가 직접 재계산하여 검증할 수 있습니다. 숨겨진 적응형 구성 요소가 없습니다. - 하나의 포트폴리오, 하나의 리스크 한도. 거래당 리스크는 고정되어 있고, 포트폴리오 전체 리스크에 상한이
필터:
리뷰 없음
리뷰 답변