Loading…

Range Scalper EA

The range is the highest high and lowest low over InpRangeBars bars. An entry only fires when the previous close sits within InpEntryBandPercent of the range width from either edge, with a stop InpStopBeyondPercent beyond that edge and a target InpTargetPercent back into the range - all three distances scale with the range's own width, so they widen and narrow with it automatically rather than using a fixed pip distance that would be too tight in a wide range and too loose in a narrow one. Range strategies are reliably destroyed by trends: a market that stops ranging and starts trending runs straight through a mean-reversion entry and out the far side of its stop. Most examples in this catalogue gate entries on a regime filter and then leave the exit entirely to a fixed stop and target once the trade is open. This EA instead keeps checking ADX(InpAdxPeriod) every bar while a position is open, and if it climbs to InpFlattenAdx or above, closes the trade immediately rather than waiting to find out whether the fixed stop was wide enough for a trend that was not supposed to be there. Position sizing can run as a fixed lot or, with InpUseRiskSizing on, as a percentage of equity risked to the range-scaled stop distance, computed from MODE_TICKVALUE and MODE_TICKSIZE rather than a hardcoded contract size. Notes and limitations - The ADX flatten check only runs once per closed bar, the same as everything else in this EA - a fast intrabar trend break can still outrun it before the next bar closes. - Entering near a range edge is not the same as the range holding; a scalp can still be stopped out on the very move the ADX filter was meant to catch, simply because ADX had not yet risen when the entry fired. - No separate trailing stop - exit is the fixed stop/target, the ADX flatten check, or manual intervention. - One position at a time, tracked by InpMagicNumber. It will not manage or interfere with trades opened manually or by another EA. - Requires AutoTrading enabled and IsTradeAllowed() true; if trading is disabled the EA logs it and skips the entry, though the ADX flatten check on an existing position still requires trading to be allowed to act on it.

Expert advisor · MT4 · v1.0 · Free

About Range Scalper EA

Range Scalper EA is an expert advisor (trading robot) for MetaTrader 4 based on ADX. It can size trades from your balance and risk percent and is built for short scalping trades. It has 14 settings, such as Range bars, Adx period and Max adx to enter. MQL source code included.

Files in the download: RangeScalperEa.ex4, RangeScalperEa.mq4, RangeScalperEa.txt.

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

Settings

SettingDefaultWhat it does
Range bars24Bars used to define the current range (high/low)
Adx period14ADX period used as the trend/range regime filter
Max adx to enter22.0Maximum ADX allowed to open a new scalp
Flatten adx30.0ADX level that flattens an open scalp early (trend emerging)
Entry band percent20.0How close to the range edge price must be to enter, percent of range width
Stop beyond percent15.0Stop distance beyond the range edge, percent of range width
Target percent50.0Take profit distance back into the range, percent of range width
Use risk sizingfalseSize by percent risk instead of a fixed lot
Risk percent0.5Percent of equity risked per trade, when risk sizing is on
Fixed lots0.10Lot size when risk sizing is off, or as a fallback
Magic number20260710Magic number for orders opened by this EA
Slippage pips3Slippage 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 · ADX · Trend · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria