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
| Setting | Default | What it does |
|---|---|---|
| Atr period | 14 | ATR period |
| Long run bars | 100 | Bars averaged to build the long-run ATR baseline |
| Base risk percent | 1.0 | Risk % of balance per trade before throttling |
| Min multiplier | 0.25 | Floor on the throttle multiplier - never shrink risk below this fraction |
| High vol trigger ratio | 1.25 | Current ATR / baseline ratio above which throttling begins |
| Stop loss pips | 20.0 | Stop distance used for the suggested lot size |
| Update every tick | false | false = recompute once per completed bar (recommended); true = every tick |
| Global variable name | VART_RiskMultiplier | Global variable other EAs can read for the current multiplier |
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: ATR · MT4 Expert Advisor · MQL4 Source Code