Loading…

Compile Time Plugin Host

A "plugin architecture" usually implies dropping new code into a running program without recompiling it. MQL4 cannot do that - there is no dynamic loading, no reflection, and every CodeBase submission has to be one self-contained file. Any plugin host built on this platform is necessarily a compile-time registry: every plugin's code is baked into the .mq4 when it is compiled, and "installing" a new plugin genuinely means editing this source and pressing F7 again. This template is upfront about that ceiling on-chart and in this document, rather than implying a runtime capability the platform does not have. What the registry pattern still buys you, even at compile time: every plugin shares one call signature (evaluate the market, return -1/0/1 and a reason string), one enable/disable input, one vote weight, and reports through one aggregation and logging path. The host's OnTick() never grows an if/else chain hardcoded per strategy - RunRegistry() fills a fixed array of plugin slots, AggregateVote() combines them into one weighted signal, and adding a fourth plugin means writing one more function and one more registry row, not restructuring OnTick(). Three demo plugins ship: a fast/slow SMA crossover, an RSI overbought/ oversold reversion, and a Donchian-channel breakout of the prior N bars. Each can be independently enabled and weighted; the aggregate vote must clear InpVoteThreshold in either direction before a trade is sent, and position sizing uses live tick value/size risk-percent sizing rather than a fixed lot. Notes and limitations - This is a compile-time plugin registry, not a runtime one. No plugin can be added, removed, or hot-swapped without editing this source file and recompiling - there is no MQL4 mechanism for genuine dynamic loading, and this template does not attempt to fake one. - The three demo plugins are simple, uncorrelated-in-concept indicators included to exercise the registry pattern, not a validated trading system - review and backtest before live use. - The registry holds a fixed PLUGIN_SLOT_COUNT of 3; a struct with a dynamic array member has no safe copy/assignment semantics in MQL4 (house style section 0.2), so the plugin table is a fixed-size array of a plain-scalar struct rather than anything dynamically sized. - Only one position per symbol/magic is opened at a time.

Expert advisor · MT5 · v1.0 · Free

About Compile Time Plugin Host

Compile Time Plugin Host is an expert advisor (trading robot) for MetaTrader 5 based on RSI and Moving Average. It can size trades from your balance and risk percent and trades breakouts. It has 18 settings, such as Enable ma cross, Weight ma cross and Enable rsi reversion. MQL source code included.

Files in the download: CompileTimePluginHost.ex5, CompileTimePluginHost.mq5, CompileTimePluginHost.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Enable ma crosstrueEnable the MA-cross plugin
Weight ma cross1.0Vote weight for the MA-cross plugin
Enable rsi reversiontrueEnable the RSI mean-reversion plugin
Weight rsi reversion1.0Vote weight for the RSI mean-reversion plugin
Enable breakouttrueEnable the Donchian breakout plugin
Weight breakout1.0Vote weight for the Donchian breakout plugin
Vote threshold0.5Net weighted vote (-1..+1) required to act
Fast ma period10MA-cross plugin: fast period
Slow ma period30MA-cross plugin: slow period
Rsi period14RSI-reversion plugin: RSI period
Rsi oversold25RSI-reversion plugin: oversold level (buy)
Rsi overbought75RSI-reversion plugin: overbought level (sell)
Breakout bars20Breakout plugin: lookback bars for the channel
Risk percent1.0Risk per trade, percent of equity
Stop loss pips25Stop-loss distance in pips
Take profit pips50Take-profit distance in pips
Magic number49100Magic number for this instance's positions
Verbose logfalsePrint every plugin's raw vote every tick

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Breakout · RSI · Channels & Envelopes · Buy/Sell Arrows · Risk & Lot Size · Moving Average · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria