Skip to content
All library documents

Volatility-Scaled Position Sizing with a Monotonic Queue and RBF Filter

Article MQL5 articles

Summary

This article presents an MQL5 money-management module that adjusts position size as the recent price range expands. It uses a monotonic queue to track rolling highs and lows, describing how each observation is added and removed at most once to achieve linear total processing time. The current range is compared with a base volatility level, and lots are scaled down when the range exceeds that reference. An optional radial basis function filter is also proposed to reduce size based on a nonlinear assessment of signal conditions, with lot values normalized to broker constraints.

The document focuses on implementation and computational reasoning, including a comparison with repeated window scans and heap-based approaches. It does not provide empirical trading results demonstrating improved returns or lower drawdowns. The author notes that copying price data and reading indicator buffers may still contribute latency, and that RBF parameters need to be set or trained and checked out of sample. The stated speed and risk benefits should therefore be profiled and validated in the intended environment.

Key ideas

  • A monotonic queue can maintain rolling price extremes with linear total processing across a series.
  • The proposed sizing rule reduces lots when the current high-low range exceeds a base volatility reference.
  • An optional RBF filter further adjusts position size based on a nonlinear signal assessment.
  • Broker lot step and minimum and maximum limits are part of the implementation.
  • The article calls for profiling data-copy latency and validating RBF settings out of sample.

Tags

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