Skip to content
All library documents

Correlation, Threshold, and Volatility Filters for Trading Signals

Code Stratmill research code

Summary

This code excerpt implements three filters intended to support spread trading and risk adjustment. The correlation filter calculates rolling correlation between the first two series, rescales it to a zero-to-one range, and uses changes in that measure to mark buy or sell events. The threshold filter assigns trade sides when an input time series crosses specified levels, then shifts the labels by one row. The volatility filter models changes in a spread with an exponentially weighted variance estimator and groups estimated volatility into regimes associated with leverage multipliers.

The excerpt includes plotting helpers, but no backtest or performance evidence. The code is incomplete, and several design choices deserve review before use: the correlation scaling is fit across the supplied sample, the stated sell-threshold comparison appears inconsistent with its parameter description, and the volatility regime logic has boundary conditions that may overlap. The one-row signal shift may help avoid same-row execution assumptions, but does not by itself establish a valid out-of-sample process or realistic trading costs.

Key ideas

  • The correlation filter uses changes in rolling correlation between two spread legs to generate directional labels.
  • The threshold filter marks entries when a series crosses configured buy or sell levels and shifts labels by one row.
  • The volatility filter estimates spread-return variance with an exponentially weighted model and assigns regime-specific leverage multipliers.
  • The excerpt supplies plotting functions but no evidence of trading performance.
  • Scaling, threshold comparisons, overlapping regime boundaries, and out-of-sample handling need careful review.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.