Framework & template · MT5

MT5 Expert Advisor Template

by EarnForex

This MetaTrader 5 expert advisor serves as a foundational framework for developing automated trading strategies.

GitHub stars31
Forks22
Last update1 year ago20 Jun 2025
LicenceApache-2.0

Overview

MT5 Expert Advisor Template streamlines the creation process by providing pre-built modules for position sizing, risk management, and trade execution. The system includes parameters for ATR-based stop-loss and take-profit calculations, fixed or percentage-based lot sizing, and trading hour filters. It also supports partial closing of positions and spread monitoring. Since it is a template, the core logic for market entry and exit must be defined by the developer.

Details

Author

EarnForex on GitHub

Type

Framework & template

Platform

MetaTrader 5 (MQL5)

Markets

Any symbol

Timeframes

Any timeframe

Risk profile

No grid, martingale or hedging logic was found in its code or README. That says nothing about how it performs: backtest it first.

Topics

expertexpert-advisorforexmetatradermetatrader5mql5mt5position-sizingrobottemplate

Input parameters

Read from MT5-EA-Template.mq5. Defaults are the author's; change them in the EA's Inputs tab.

NameTypeDefaultDescription
Comment_0string==========EA-Specific Parameters
Comment_1string==========Trading Hours Settings
UseTradingHoursboolfalseLimit trading hours
TradingHourStartENUM_HOURh07Trading start hour (Broker server hour)
TradingHourEndENUM_HOURh19Trading end hour (Broker server hour)
Comment_2string==========ATR Settings
ATRPeriodint100ATR period
ATRTimeFrameENUM_TIMEFRAMESPERIOD_CURRENTATR timeframe
ATRMultiplierSLdouble2ATR multiplier for stop-loss
ATRMultiplierTPdouble3ATR multiplier for take-profit
Comment_astring==========Risk Management Settings
RiskDefaultSizeENUM_RISK_DEFAULT_SIZERISK_DEFAULT_FIXEDPosition size mode
Show all 36 inputs
NameTypeDefaultDescription
DefaultLotSizedouble0.01Position size (if fixed or if no stop loss defined)
RiskBaseENUM_RISK_BASERISK_BASE_BALANCERisk base
MaxRiskPerTradeint2Percentage to risk each trade
MinLotSizedouble0.01Minimum position size allowed
MaxLotSizedouble100Maximum position size allowed
MaxPositionsint1Maximum number of positions for this EA
Comment_bstring==========Stop-Loss and Take-Profit Settings
StopLossModeENUM_MODE_SLSL_FIXEDStop-loss mode
DefaultStopLossint0Default stop-loss in points (0 = no stop-loss)
MinStopLossint0Minimum allowed stop-loss in points
MaxStopLossint5000Maximum allowed stop-loss in points
TakeProfitModeENUM_MODE_TPTP_FIXEDTake-profit mode
DefaultTakeProfitint0Default take-profit in points (0 = no take-profit)
MinTakeProfitint0Minimum allowed take-profit in points
MaxTakeProfitint5000Maximum allowed take-profit in points
Comment_cstring==========Partial Close Settings
UsePartialCloseboolfalseUse partial close
PartialClosePercdouble50Partial close percentage
ATRMultiplierPCdouble1ATR multiplier for partial close
Comment_dstring==========Additional Settings
MagicNumberint0Magic number
OrderNotestringComment for orders
Slippageint5Slippage in points
MaxSpreadint50Maximum allowed spread to trade, in points

How to install it

  1. 1Download the sourceUse "Download source (.zip)" above, or clone EarnForex/MT5-Expert-Advisor-Template from GitHub, and unzip it.
  2. 2Open the data folderIn MetaTrader choose File, then Open Data Folder, and go to MQL5/Experts.
  3. 3Copy the filesCopy the .mq5 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

EA31337 Classes

by EA31337
269 stars

This development framework provides a comprehensive MQL library for building Expert Advisors, indicators, and scripts across MetaTrader 4 and 5 platforms. It facilitates cross-platform compatibility by offering a unified API that allows developers to port MQL4 code to MQL5 with minimal modifications. The library includ

MT5 Framework & template
Updated 5 months ago GPL-3.0 GitHub repository of EA31337 Classes
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

ICT Library MQ5

by xxvw
205 stars

This MetaTrader 5 library and expert advisor automates Smart Money Concepts (SMC) and Inner Circle Trader (ICT) methodologies. It identifies market structure shifts, breaks of structure, order blocks, and liquidity zones. The system features a confluence-based entry mechanism that evaluates signals against kill zones,

MT5 Framework & template SMC / ICT / price action

Roffild Library

by Roffild
120 stars

Roffild Library is an extensive framework and collection of expert advisors for MetaTrader 5 that bridges MQL5 with modern data science tools. It provides functional implementations for machine learning models, specifically Multilayer Perceptron neural networks and Random Forests via the AlgLib library. The project fac

MT5 Framework & template AI / machine learning
Updated 6 years ago Apache-2.0 GitHub repository of Roffild Library

Orchard Forex Framework 3

by OrchardForexTutorials
64 stars

Orchard Forex Framework 3 is an educational development library for MetaTrader 5. It provides a structured foundation for building Expert Advisors using object-oriented programming. The repository includes base classes for handling trades, managing positions, and integrating common technical indicators like RSI, MACD,

MT5 Framework & template Grid High risk
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

More frameworks and templates

Need a broker for MT5?

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

Compare brokers