Skip to content
All library documents

Rolling Futures Positions Before Contract Expiration

Article MQL5 code base

Summary

The Expert Advisor demonstrates how to move positions from an expiring futures contract to its successor. It manages three instruments specified through input parameters. For each instrument, the configured volume determines both the position size and direction: positive values indicate buys, while negative values indicate sells. A user-set lead time determines how many hours before expiration the system closes the current contract position and opens a position in the new futures symbol.

The example concerns contract continuity and automated rollover, not a method for choosing market exposure. The document does not describe how successor contracts are identified, how prices or contract specifications are reconciled, or how transaction costs and liquidity are handled. It also provides no performance evidence or risk-management guidance. Its practical scope is a demonstration of expiration-based switching with fixed, user-specified positions across three instruments.

Key ideas

  • The Expert Advisor demonstrates switching futures positions ahead of contract expiration.
  • It manages three instruments whose symbols are supplied as inputs.
  • Positive configured volumes represent buys, and negative volumes represent sells.
  • A configurable number of hours before expiration triggers closing the old position and opening the successor contract.
  • The description does not address rollover costs, contract matching, or how position sizes are selected.

Tags

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