Loading…

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

SettingDefaultWhat it does
Fast ma period10Short moving average the price reverts toward
Ma methodMODE_SMAMoving average method
Entry deviation atr1.2Minimum |price - MA| distance to consider trading, in ATR multiples
Cost multiple3.0Expected reversion distance must exceed this many round-trip costs
Commission per lot0.0Round-trip commission per standard lot, in account currency (0 = spread-only cost)
Atr period14ATR period used both for the deviation filter and the stop
Stop atr multiple1.0Stop distance beyond entry, in ATR multiples
Max holding bars6Force-close if the scalp has not resolved within this many bars
Risk percent0.5Risk per trade, percent of equity
Magic number20260906Magic number for orders opened by this EA
Slippage pips2Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Scalping · Moving Average · Buy/Sell Arrows · Risk & Lot Size · ATR · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria