Loading…

Execution Model Teaching EA

The same gross trading result can look very different net of costs depending purely on how those costs are charged. This EA makes that concrete: a single synthetic sequence of GROSS trade outcomes (a fixed win rate, fixed target and stop in points, generated once with a seeded random source) is run through five cost models at once, so every model sees the identical gross trades and only the deduction differs. Money-per-point is computed from MODE_TICKVALUE and MODE_TICKSIZE read live for the attached symbol, never from an assumed contract size - the same points-to-money conversion this catalogue uses everywhere trading money is calculated, since Gold, an index and a JPY cross all convert differently. The lot size is normalised to the broker's own min/max/step grid before use, exactly as a real order would be, even though no order is ever sent. The five models are: gross with no costs at all; a fixed spread in points charged once per trade; a live spread snapshot taken from MODE_SPREAD at the moment the EA runs; a fixed commission per lot, per round turn; and a percentage of the trade's notional value (lots times the broker's own MODE_LOTSIZE contract size times the current price). The CSV report lays out the cumulative net result of all five side by side, trade by trade, plus a final summary. Notes and limitations - Report-only. No order is ever sent; every "trade" is a synthetic gross point outcome with a cost model applied arithmetically. - The "live spread snapshot" model uses ONE reading of MODE_SPREAD, taken once when the simulation runs - it demonstrates what a constant real-world spread figure would have cost, not a spread that varies trade to trade the way a live account's actually does. - The synthetic trade sequence is a fixed win-rate, fixed target/stop model. It says nothing about any real strategy's actual results - use this EA to compare cost MODELS against each other on identical gross trades, not to estimate a real strategy's net profitability. - The simulation runs exactly once, on the first tick after attach. Changing an input requires removing and re-attaching the EA to re-run with the new values.

Expert advisor · MT5 · v1.0 · Free

About Execution Model Teaching EA

Execution Model Teaching EA is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 10 settings, such as Num trades, Win rate percent and Target points. MQL source code included.

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

Settings

SettingDefaultWhat it does
Num trades300Number of synthetic trades to simulate (capped, see .txt)
Win rate percent45.0Probability a synthetic trade is a winner
Target points200Gross points gained on a winning trade
Stop points100Gross points lost on a losing trade
Lot size0.10Lot size used for every synthetic trade (normalised to the broker's grid)
Random seed42Seed for MathSrand - same seed reproduces the same run
Fixed spread points20"Fixed spread" model: constant spread charged once per trade
Commission per lot round turn7.0"Fixed commission" model: currency units per lot, per round turn
Commission percent of notional0.01"Percentage of notional" model: percent of trade notional value
Report file nameExecutionModelTeachingEa_report.csvReport file, written under MQL5\Files\

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 → Scripts.
  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 script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria