Risk Sentiment Composite Gauge
"Risk-on" and "risk-off" are read constantly in market commentary, but which instruments actually represent each side is a judgement call that shifts across regimes and depends on what a trader is trading - a hardcoded fixed list quickly goes stale (a "safe haven" in one decade is not necessarily one the next). This gauge takes both baskets as plain user input instead. It measures each configured safe-haven symbol's and risk-proxy symbol's percentage change over InpLookbackBars, averages each basket, and scores the spread (risk-proxy average minus safe-haven average) normalised against its own recent range so the gauge stays within a consistent -100..+100 band regardless of how volatile the chosen instruments are in absolute percentage terms. A positive gauge means the risk proxies are outperforming the havens (risk-on); negative means the reverse (risk-off). Normalising the raw spread against its own trailing window - rather than a fixed scale - is what keeps the gauge meaningful across different basket choices: a basket of volatile index/commodity proxies and a basket of quiet FX pairs would otherwise sit on completely different raw scales and be impossible to compare sign-only. Notes and limitations The classification of "safe haven" versus "risk proxy" is entirely the trader's own input - the indicator has no built-in opinion and will happily compute a spread between any two basket choices, sensible or not. Symbols with insufficient history are excluded from that basket's average for the affected bars rather than read as a false 0%. History depth is capped on first calculation (1000 bars) to bound the cost of recomputing both baskets across the chart.
Indicator · MT4 · v1.0 · Free
About Risk Sentiment Composite Gauge
Risk Sentiment Composite Gauge is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message and is set up for gold (XAUUSD). It has 6 settings, such as Safe haven symbols, Risk proxy symbols and Timeframe. MQL source code included.
Files in the download: RiskSentimentGauge.mq4, RiskSentimentGauge.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Safe haven symbols | USDJPY,USDCHF,XAUUSD | Comma-separated safe-haven symbols (broker names, no spaces) |
| Risk proxy symbols | AUDUSD,NZDUSD,US500 | Comma-separated risk-proxy symbols (broker names, no spaces) |
| Timeframe | PERIOD_H1 | Timeframe the percentage change is measured on |
| Lookback bars | 24 | Bars back the percentage change is measured over |
| Normalise window | 100 | Bars back used to scale the raw spread to +-100 |
| Alert on flip | false | Alert once when the gauge changes sign on a new closed bar |
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 → Indicators.
- 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 indicator from the Navigator onto a chart and adjust the settings.
Tags: Alerts · Gold (XAUUSD) · MT4 Indicator · MQL4 Source Code