Bar Versus Tick Execution Demo
"It worked in the tester but not live" is usually a symptom of one specific mistake: logic that reads price on every tick instead of gating on Time[0] changing, so it reacts to a bar that has not actually closed yet. In the Strategy Tester's "every tick" mode this can still look consistent, because the tester replays real intrabar ticks. Live, or in "open prices only" tester mode, the same code behaves completely differently, because the values it is reading move underneath it before the bar it thinks it is reacting to ever finishes forming. This EA makes that mistake visible instead of theoretical. The same fast/slow SMA cross runs as two independent, entirely paper positions: "bar mode" reads the cross only from the last two closed bars, the way any correctly gated EA does. "Tick mode" recomputes the identical average pair against the current forming bar on every tick, the way an EA that forgot to check for a new bar does. Tick mode can flip direction several times before bar mode ever sees a signal on that bar at all - each flip is counted, both for the bar currently forming and as a running total, and that count is exactly the number of decisions a once-per-bar backtest never made but a naive live EA did. No real order is ever sent. Both modes track a simulated profit and loss using the broker's actual tick value and tick size, so even the paper numbers price correctly on gold, indices and JPY pairs, but the money figures exist for scale, not as a claim about which mode is "better" - that depends entirely on the strategy. Notes and limitations - Purely educational. No order-sending call exists anywhere in either file. - The "flips on the current still-forming bar" counter resets to zero at every new bar; "total flips ever" accumulates for the life of the chart attachment. - Tick mode's simulated entry and exit price is always the current Bid, the same simplification bar mode uses, so the comparison is about timing and flip frequency, not spread or slippage modelling. - This does not diagnose the Strategy Tester's modelling-quality setting directly - it demonstrates the underlying mechanism that setting controls.
Expert advisor · MT4 · v1.0 · Free
About Bar Versus Tick Execution Demo
Bar Versus Tick Execution Demo is a script for MetaTrader 4 based on Moving Average. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Fast ma period, Slow ma period and Virtual lots. MQL source code included.
Files in the download: BarVersusTickExecutionDemo.ex4, BarVersusTickExecutionDemo.mq4, BarVersusTickExecutionDemo.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Fast ma period | 10 | Fast SMA period, shared by both modes |
| Slow ma period | 30 | Slow SMA period, shared by both modes |
| Virtual lots | 0.10 | Paper lot size used only to price the simulated P/L in money terms |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Divergence · Alerts · Moving Average · MT4 Expert Advisor · MQL4 Source Code