Skip to content
All library documents

Closing Short Futures Positions with a Moving-Average Condition

Article SuperMind

Summary

The example pairs a ten-day simple average of futures closing prices with the prior close to control a short position. It opens a short position when the prior close is below the average and the existing position is under a stated size threshold. When the prior close rises above the average and a short position exists, it submits an order with a negative quantity, apparently intended to reduce or close that position. The code also logs an order message and a close message.

This is a small code illustration rather than a complete trading method. It does not clarify the platform’s order semantics, whether the negative quantity closes only the existing exposure, or how partial fills and position limits are handled. It also omits contract selection, transaction costs, stop conditions, and any backtest or live results. The moving-average rule is presented without evidence that it is profitable or suitable across futures markets.

Key ideas

  • The example compares the prior close with a ten-day average of closing prices.
  • It opens a short position when price is below the average and the position is below a size limit.
  • A negative-quantity order is used when price rises above the average and a short position is open.
  • The snippet does not show execution handling, risk controls, or strategy performance.

Tags

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