GuardRails is a MetaTrader 5 trade management and execution system that pairs an MQL5 EA bridge with a self-hosted Python FastAPI backend and Discord bot.
GuardRails executes trades requested via Discord commands and runs built-in multi-strategy portfolio EAs. The system enforces strict risk controls, including hardcoded daily loss limits, maximum open position caps, fixed percentage risk per trade, and peak drawdown protection. It features automated position sizing, stop-loss and take-profit calculations, and live alerts for fills and risk breaches.
Read from MetaEq.mq5. Defaults are the author's; change them in the EA's Inputs tab.
Name
Type
Default
Description
GlobalBaseMagic
int
100000
Base magic number (S1 = +1000.., S2A = +2000.., S2B = +4000.., S3 = +3000..)
GlobalComment
string
MotherEA
Comment written on every trade
GlobalPreventOverlap
bool
true
Block the strategies from both going long on the same symbol
GlobalUseFixedBalance
bool
false
Size S2A/S2B risk on a fixed balance (non-compounding, for testing)
GlobalFixedBalance
double
100000.0
Fixed balance used when the option above is on
GlobalRandomSeed
int
0
RNG seed for the randomizers (0 = time-based, fixed value reproduces tests)
GlobalMaxDailyDDPercent
double
0.0
Max daily drawdown % of day-start equity (0 = off)
GlobalMaxTotalDDPercent
double
0.0
Max total drawdown % from peak equity (0 = off)
GlobalMaxOpenPositions
int
0
Max open positions across all strategies (0 = no limit)
S1_Enabled
bool
true
S1: enabled
S1_Symbols
string
CURRENT
S1: symbols (pipe separated, CURRENT = chart symbol)
S1_Timeframes
string
M15
S1: confirmation timeframe per symbol (pipe separated)
Show all 40 inputs
Name
Type
Default
Description
S1_ATR_Period
int
5
S1: ATR period (Daily)
S1_ATR_Multiplier
double
0.25
S1: ATR multiplier for breakout levels
S1_Stop_ATR_Multiplier
double
0.25
S1: ATR multiplier for stop loss
S1_Use_Candle_Close
bool
true
S1: require candle close confirmation
S1_ATR_Short_Period
int
1
S1: short-term ATR period (Daily)
S1_ATR_Long_Period
int
5
S1: long-term ATR period (Daily)
S1_ATR_Regime_Factor
double
1.0
S1: regime factor
S1_Regime_Filter_Mode
ENUM_REGIME_MODE
REGIME_LOW_VOLATILITY
S1: regime filter mode
S1_Trade_Direction
ENUM_TRADE_DIRECTION
TRADE_BOTH
S1: allowed trade direction
S1_Reverse_Mode
bool
false
S1: reverse mode (fade the breakout)
S1_Fixed_Risk_Amount
double
500.0
S1: fixed risk amount (account currency)
S1_Entry_Time
string
16:30
S1: entry window start (HH:MM, server time)
S1_Max_Entry_Time
string
18:05
S1: latest entry time (HH:MM, server time)
S1_Exit_Time
string
22:55
S1: close all positions time (HH:MM, server time)
S1_EnableRandomization
bool
false
S1: randomizer master switch (OFF = exact original behavior)
S1_RandomDelayMaxSec
double
0.0
S1: max random entry delay, seconds (0 = immediately)
S1_RandomVolumeJitterPct
double
0.0
S1: volume jitter +/- percent (0 = off)
S1_RandomSlJitterPoints
double
0.0
S1: SL distance jitter +/- points (0 = off)
S2A_Enabled
bool
true
S2A: enabled
S2A_Symbols
string
BTCUSD|XAUUSD|USDJPY
S2A: symbols (pipe separated, ALL or CURRENT)
S2A_Timeframes
string
CURRENT
S2A: timeframe per symbol (pipe separated, CURRENT = chart timeframe)
S2A_EMALength
int
200
S2A: EMA length
S2A_BreakoutBars
int
3
S2A: breakout bars
S2A_StopLossBars
int
5
S2A: stop loss lookback period
S2A_RiskPerTrade
double
0.01
S2A: risk per trade as a fraction of equity (0.01 = 1%)
S2A_AllowMultiplePositions
bool
true
S2A: enable pyramiding (multiple positions per symbol)
S2A_MaxPositions
int
5
S2A: maximum positions per symbol
S2A_EnableRandomization
bool
false
S2A: randomizer master switch (OFF = exact original behavior)
How to Install It
1Download the sourceUse "Download source (.zip)" above, or clone jobmwitah/GuardRails from GitHub, and unzip it.
2Open the data folderIn MetaTrader choose File, then Open Data Folder, and go to MQL5/Experts.
3Copy the filesCopy the .mq5 file into Experts.
4Compile in MetaEditorOpen the file in MetaEditor and press Compile. Fix any missing includes the compiler reports.
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.
This repository contains a diverse collection of MetaTrader 5 expert advisors ranging from RSI-based scalping robots to multi-timeframe trend following systems. The EAs utilize various technical indicators including EMA crossovers, MACD momentum, and ATR for volatility-based exits. The core logic often incorporates mul
This expert advisor for MetaTrader 5 is a multi-strategy system that utilizes market regime detection to switch between trend following, range trading, and breakout modes. It incorporates a wide array of technical indicators, including Moving Averages, RSI, MACD, Ichimoku, and SuperTrend. The bot manages risk through v
This collection for MetaTrader 5 provides several automated Expert Advisors designed for various symbols including forex, gold, and indices. The repository features Mecha Godzilla, a grid trading system using ATR-based spacing and bidirectional orders, alongside specialized bots for Asian session breakouts and H4 trend
This MetaTrader 5 expert advisor is designed for gold trading using an adaptive, modular architecture. It features a regime detector that switches between trend-following, mean reversion, and breakout strategies based on market conditions. The system utilizes exponential moving averages, ADX for trend strength, and RSI
Smart Trader 7CAS is an automated trading robot for MetaTrader 5 designed specifically for commodities including Gold, Silver, and Oil. It implements seven distinct trading modules or scenarios covering trend following, scalping, range trading, breakouts, Smart Money Concepts, reversals, and Fibonacci levels. The syste
The Gold Reaper is a multi-strategy expert advisor for MetaTrader 4 and 5. It trades gold pairs using breakout and reversal entries based on fractals and ATR. Trades enter when spread and frequency conditions are met and exit via trailing stops or time-based rules. The EA includes NFP filters to pause during economic e