Skip to main content

[SF] VaR: excess deviation from the mean

The [SF] VaR indicator shows how much further than the benchmark an asset has moved from its moving average over the last n bars. It is not the classic Value at Risk.

VaR indicator below the chart.

The [SF] VaR indicator below the chart.

What it is​

In the indicator list it is called [SFQA] Value at risk; on the chart it is labeled [SF] VaR. The name is historical: the indicator does not compute Value at Risk and does not compute a risk premium. A more honest name for what it computes is excess deviation from the mean: how much the deviation of the asset's price from its moving average changed over the last nn bars compared with the same measure for the benchmark, minus the risk-free rate over that time.

The indicator is available on all plans.

note

The classic Value at Risk is the loss that, with a given probability (for example, 95%), will not be exceeded over a given period. It is calculated from the distribution of returns. The risk premium is the difference between an asset's expected return and the risk-free rate. [SF] VaR does neither.

How it is calculated​

The bar price is the typical price Pt=(Ht+Lt+Ct)/3P_t = (H_t + L_t + C_t)/3. For the asset and for the benchmark, the deviation from the simple moving average over nn bars is calculated:

dt=Pt−SMAn(P)tPtd_t = \dfrac{P_t - SMA_n(P)_t}{P_t}

The change in this deviation over nn bars:

Rt=dt−dt−nR_t = d_t - d_{t-n}

The final value:

VaRt=(Rta−Rtb−ΔT×RFR100)×100VaR_t = \left(R^{a}_t - R^{b}_t - \Delta T × \dfrac{RFR}{100}\right) × 100

where RaR^{a} is the asset's measure, RbR^{b} is the benchmark's measure, ΔT\Delta T is the time taken by the last nn bars, in years, and RFRRFR is the risk-free rate in percent per year.

The risk-free rate over the last nn bars is subtracted in the same percent units as the difference between the asset and the benchmark. A year is taken as 365 days. For example, on 10 hourly bars at a rate of 10.95% the adjustment is 10.95×10/8760≈0.012510.95 × 10 / 8760 ≈ 0.0125.

Settings​

ParameterDefaultWhat it sets
SymbolemptyAsset. Empty means the chart ticker
Benchmark tikerBINANCE:BTCUSDTBenchmark
Risk free rate10.95Risk-free rate, % per year
Length10Length nn in bars

The line is green when the value is zero or above and red when it is below zero. In the Style tab you can turn on the ±2 and ±4 levels; they are hidden by default.

How to read it​

  • Value above zero: over the last nn bars the asset moved up from its average more than the benchmark moved from its own (or moved down less). The asset is stronger than the market.
  • Value below zero: the asset is weaker than the benchmark.
  • Sign change: relative strength has passed from the asset to the benchmark or back.

The indicator compares deviations from averages, not returns. So it reacts to a move speeding up or slowing down, not to its overall size, and it quickly returns to zero when the asset and the benchmark move the same way.

Limitations​

  • It is not a risk measure. The indicator cannot tell you how much you can lose on a position.
  • The value depends on the chosen benchmark. For altcoins the default is BTCUSDT.
  • The risk-free rate is subtracted as a fixed adjustment and has almost no effect on the result.