Cost Gated Reversion Scalper
A scalping signal measured in pips is meaningless without comparing it to what the round trip actually costs. This EA measures the deviation between price and a short moving average in real price terms, then converts the CURRENT spread (read fresh every bar, not a fixed assumption) plus an optional per-lot commission input into that same price terms using the symbol's own tick value - never a hardcoded pip value or contract size, so it scales correctly on any instrument. A trade is only taken when the deviation clears both a minimum ATR-scaled distance filter AND InpCostMultiple times that live round-trip cost; a three-pip signal on a symbol whose spread alone costs two pips is refused, not taken on the hope that it works out. The take-profit target is the moving average itself - the trade exists to capture the reversion distance the cost gate already confirmed is worth taking, not to chase further. A fixed ATR-based stop and a holding-bar cap keep a scalp from turning into an unmanaged swing position if the reversion stalls. Notes and limitations - The cost gate only models spread and an optional flat commission input; it does not model swap, slippage beyond InpSlippagePips, or any broker-side markup not reflected in the quoted spread. - Only one position is held at a time. - Targeting the moving average itself means the trade can be stopped out before reaching a target that keeps moving as new bars form; the target is recomputed fresh at entry, not tracked live thereafter. - Intended for low timeframes; on a high timeframe the ATR-based distance filter and cost gate are still applied correctly, but the "scalp" framing (fast reversion, short holding cap) stops matching the trade's actual holding period.
Expert advisor · MT4 · v1.0 · Free
About Cost Gated Reversion Scalper
Cost Gated Reversion Scalper is an expert advisor (trading robot) for MetaTrader 4 based on Moving Average and ATR. It can size trades from your balance and risk percent and is built for short scalping trades. It has 13 settings, such as Fast ma period, Ma method and Entry deviation atr. MQL source code included.
Files in the download: CostGatedReversionScalper.ex4, CostGatedReversionScalper.mq4, CostGatedReversionScalper.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Fast ma period | 10 | Short moving average the price reverts toward |
| Ma method | MODE_SMA | Moving average method |
| Entry deviation atr | 1.2 | Minimum |price - MA| distance to consider trading, in ATR multiples |
| Cost multiple | 3.0 | Expected reversion distance must exceed this many round-trip costs |
| Commission per lot | 0.0 | Round-trip commission per standard lot, in account currency (0 = spread-only cost) |
| Atr period | 14 | ATR period used both for the deviation filter and the stop |
| Stop atr multiple | 1.0 | Stop distance beyond entry, in ATR multiples |
| Max holding bars | 6 | Force-close if the scalp has not resolved within this many bars |
| Risk percent | 0.5 | Risk per trade, percent of equity |
| Magic number | 20260906 | Magic number for orders opened by this EA |
| Slippage pips | 2 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
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 → Experts.
- 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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Scalping · Moving Average · Buy/Sell Arrows · Risk & Lot Size · ATR · MT4 Expert Advisor · MQL4 Source Code