
An educational example of a simple trend-following Expert Advisor. It shows how to structure a trading robot in MQL5: signal on closed bars, order execution with checks and retries, and safe handling of a terminal restart.
Strategy
What the code demonstrates
Inputs
Important This is an educational example, not a trading system. It works only on demo accounts and in the Strategy Tester – on a live account it shows a message and stops. Provided "as is", without any warranty. Not investment advice. Trading Forex and CFDs involves a high risk of losing capital. License: FxCraft Example EA License (see the source header).
AttachExpert: attach an EA with inputs to a chart from code
AttachExpert.mqh attaches an Expert Advisor to a chart from MQL5 code, with the inputs you choose and with "Allow Algo Trading" on or off.
News Lines Utility – Economic Calendar Lines and Event Panel
Short description (for the "Short description" field) Shows economic news events directly on your chart as colour-coded vertical lines with tooltips, plus a draggable event panel with upcoming and recent releases. Works on every symbol and timeframe, with filters for impact level and instrument groups (Gold & Silver, Forex Majors, Indices, Oil & Gas).
FxCraft Example EA – Bollinger Bands mean reversion
Educational Expert Advisor: Bollinger Bands return to the mean with an optional RSI filter and trading hours. Clean, commented MQL5 code with margin, volume and stop level checks. Demo and Strategy Tester only.
FxCraft Example EA – Range Breakout with pending orders
Educational Expert Advisor: daily range breakout with BuyStop/SellStop pending orders, risk-reward take profit and trading days. Clean, commented MQL5 code with margin and stop level checks. Demo and Strategy Tester only.