Loading…

Volatility Adjusted Risk Throttle

A fixed risk percentage per trade means a fixed money loss on a normal stop, but the stop distance itself usually widens with volatility, and few traders recompute their percentage by hand every time the market speeds up. This EA recomputes it for them: it takes the mean of the last N completed bars' ATR as a long-run baseline, compares the most recently completed bar's ATR against it, and when the ratio crosses a configurable trigger, shrinks a base risk percentage in proportion to how far above the trigger the market has run - never below a configurable floor, so the throttle cannot suggest zero size outright. The baseline is built exclusively from completed bars (shift 1 upward), never the forming bar, so it does not drift on every tick as the current bar develops. By default the comparison itself also only updates once per bar close, which keeps the multiplier stepping cleanly rather than jittering intrabar; a per-tick option is offered for traders who want faster reaction and accept a noisier number. The result is published two ways. The chart comment shows the full working - current ATR, baseline, ratio, multiplier, throttled risk percentage and a suggested lot size for a configured stop distance, computed from tick value and tick size so it stays correct on metals, indices and JPY crosses. The multiplier is also written to a global variable with a configurable name, so any other EA running in the same terminal can read it with GlobalVariableGet() and scale its own position sizing, without this program needing to know anything about that EA's code. The global variable is deleted again on removal, so a stale multiplier is never left behind for something else to read after this EA is gone. Notes and limitations This EA never places, modifies or closes an order - it is a calculator and a publisher, nothing more. The published multiplier only exists while this EA is attached to a chart and running; a consuming EA should treat a missing or stale global variable as "no throttle information available" rather than assuming a multiplier of 1.0. ATR itself lags genuine volatility shifts by its period, so the throttle reacts to a regime change slightly after it starts, not the instant it starts.

Expert advisor · MT4 · v1.0 · Free

About Volatility Adjusted Risk Throttle

Volatility Adjusted Risk Throttle is a script for MetaTrader 4 based on ATR. It has 8 settings, such as Atr period, Long run bars and Base risk percent. MQL source code included.

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

Settings

SettingDefaultWhat it does
Atr period14ATR period
Long run bars100Bars averaged to build the long-run ATR baseline
Base risk percent1.0Risk % of balance per trade before throttling
Min multiplier0.25Floor on the throttle multiplier - never shrink risk below this fraction
High vol trigger ratio1.25Current ATR / baseline ratio above which throttling begins
Stop loss pips20.0Stop distance used for the suggested lot size
Update every tickfalsefalse = recompute once per completed bar (recommended); true = every tick
Global variable nameVART_RiskMultiplierGlobal variable other EAs can read for the current multiplier

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

Download the PDF guide

Tags: ATR · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria