Framework & template · MT4

Advanced MQ4 Expert Advisor Templates

by sibvic

This Expert Advisor framework for MetaTrader 4 provides a modular template for building custom trading strategies.

High risk

GitHub stars86
Forks39
Last update2 months ago10 Jul 2026
LicenceMIT
Latest release2025-1010 months ago

Overview

Advanced MQ4 Expert Advisor Templates handles complex trade management tasks, including multi-symbol execution, margin-based position capping, and various lot-sizing algorithms such as risk percentage or fixed volume. Risk controls include ECN-compatible hidden stops, ATR-based trailing stops, and multi-level breakeven settings. While it supports optional martingale lot scaling and directional logic toggles, the core entry and exit conditions must be defined by the developer. It includes built-in logging, account statistics, and time-based trading restrictions.

Details

Author

sibvic on GitHub

Type

Framework & template

Platform

MetaTrader 4 (MQL4)

Strategy

Martingale

Markets

Any symbol

Timeframes

Any timeframe

Risk profile

  • Uses martingale lot scaling: losses can grow fast

Input parameters

Read from EA_Base.mq4. Defaults are the author's; change them in the EA's Inputs tab.

NameTypeDefaultDescription
GeneralSectionstringGeneral
symbolsstringSymbols to trade. Comma-separated. Use empty for on-chart symbol
GeneralSectionDescstringhttps://github.com/sibvic/mq4-templates/wiki/EA_Base-templatDescription of parameters could be found at
trading_timeframeENUM_TIMEFRAMESPERIOD_CURRENTTrading timeframe
ecn_brokerboolfalseUse hidden stop loss/take profit?
entry_logicTradingModeTradingModeLiveEntry logic
exit_logicTradingModeTradingModeLiveExit logic
lots_valuedouble0.1Position size
lots_typePositionSizeTypePositionSizeContractPosition size type
slippage_pointsint3Slippage, points
trading_sideTradingSideBothSidesWhat trades should be taken
logic_directionLogicDirectionDirectLogicLogic type
Show all 40 inputs
NameTypeDefaultDescription
max_spreaddouble0Max spred, pips. 0 to disable
close_on_oppositebooltrueClose on opposite signal
CapSectionstringPosition cap
position_capboolfalsePosition Cap
no_of_positionsint1Max # of buy+sell positions
no_of_buy_positionint1Max # of buy positions
no_of_sell_positionint1Max # of sell positions
cap_by_marginboolfalseCap by usable margin
min_margindouble50Min usable margin
MartingaleSectionstringMartingale
martingale_typeMartingaleTypeMartingaleDoNotUseMartingale type
martingale_lot_sizing_typeMartingaleLotSizingTypeMartingaleLotSizingNoMartingale lot sizing type
martingale_lot_valuedouble1.5Matringale lot sizing value
martingale_stepdouble50Open matringale position step
max_longsint5Max long positions
max_shortsint5Max short positions
StopLossSectionstringStop loss
stop_loss_typeStopLossTypeSLDoNotUseStop loss type
use_net_stop_lossboolfalseUse net stop loss
stop_loss_valuedouble10Stop loss value
stop_loss_atr_multiplicatordouble1Stop loss multiplicator (for ATR SL)
trailing_typeTrailingTypeTrailingDontUseTrailing start type
trailing_startdouble0Min distance to order to activate the trailing
trailing_target_typeTrailingTargetTypeTrailingTargetStepTrailing target
trailing_stepdouble10Trailing step
trailing_ma_lengthint14Trailing MA Length
trailing_ma_typeMATypesma_smaTrailing MA Type
BreakevenSectionstringBreakeven

How to install it

  1. 1Download the sourceUse "Download source (.zip)" above, or clone sibvic/mq4-templates from GitHub, and unzip it.
  2. 2Open the data folderIn MetaTrader choose File, then Open Data Folder, and go to MQL4/Experts.
  3. 3Copy the filesCopy the .mq4 file into Experts, and any .mqh files into the Include folder the code expects.
  4. 4Compile in MetaEditorOpen the file in MetaEditor and press Compile. Fix any missing includes the compiler reports.
  5. 5Test before you tradeRun it in the Strategy Tester, then attach it to a demo chart and allow algorithmic trading.
Third-party code. ForexR did not write, test or endorse this EA, and the summary above was generated automatically from its README and code. ForexR lists only repositories with readable source code and never hosts files. Read the code, backtest it and use a demo account first; automated trading can lose money quickly.

Similar expert advisors

Modular Trade System

by michaelwade
58 stars

This MetaTrader 4 template provides a modular framework for developing expert advisors. It organizes trading logic into decoupled components including signal engines, order management, and environment checking. The system uses an abstract controller class to handle data processing from multiple sources, such as MACD or

MT4 Framework & template MartingaleIndicator crossover High risk
Updated 6 years ago Apache-2.0 GitHub repository of Modular Trade System
36 stars

This repository contains the MQL source code used by Forex Strategy Builder Professional to export automated trading strategies to MetaTrader 4 and MetaTrader 5. It serves as a standardized template for executing technical strategies generated by the software, handling order execution and trade management. The EA inclu

MT4MT5 Framework & template Multi-strategyMartingale High risk
Updated 4 years ago None stated GitHub repository of FSB Pro Expert Advisor
7 stars

This MetaTrader 4 expert advisor provides a robust framework for developing automated trading strategies. It includes pre-built modules for trend detection using ADX and Moving Averages, alongside pullback entry logic. The template emphasizes risk management, featuring percentage-based lot sizing and adaptive volatilit

MT4 Framework & template Trend followingMean reversionMartingale High risk
Updated 5 years ago None stated GitHub repository of Falcon Trading Bot Template
234 stars

This is a modular MetaTrader 5 expert advisor framework designed to accelerate the development of custom trading strategies. It provides a standardized base that includes position management, risk controls, and multi-symbol support. The template features configurable entry and exit logic, integrated stop loss and take

MT5 Framework & template Martingale High risk
2 stars

This MetaTrader 5 framework provides a modular library for technical analysis, including candle pattern detection, support and resistance levels, and Fibonacci calculations. The repository includes an expert advisor that implements ZigZag-based wave analysis to identify market structure and chart patterns. It features

MT5 Framework & template SMC / ICT / price actionTrend followingMartingale High risk

CBMQL MQL5 Framework

by HarryWarre
2 stars

CBMQL is a development framework and build tool for MetaTrader 5 designed to modularize Expert Advisor code. Inspired by modern web development bundlers, it allows developers to break complex trading systems into reusable modules and bundle them into a single portable file. The system includes a Node.js-based environme

MT5 Framework & template Trend followingGridMartingale High risk

More frameworks and templates

Need a broker for MT4?

Compare regulated brokers that support MetaTrader, with spreads, minimum deposits and leverage side by side.

Compare brokers