Double Moving Average Crossovers with Stop Losses and Local Position Tracking
Summary
The document describes a long and short strategy driven by fast and slow moving averages. It checks crossover conditions using completed-bar values, then opens a position or reverses an existing one. Position size is calculated from current account assets, the entry price, and contract value. Stops close long positions after a specified decline and short positions after a specified rise.
The implementation keeps direction, quantity, and entry price in memory, which avoids repeated database reads during backtests. It records trades and equity changes, and loops over combinations of moving-average lengths for parameter testing. The document gives implementation details but no performance results or comparison against a benchmark. Its stated limitation is that restarting the live process resets the in-memory position record; contract settings and execution behavior may also require adjustment for other instruments or venues.
Key ideas
- The strategy uses fast and slow moving-average crossovers to enter or reverse long and short positions.
- It evaluates signals from completed bars to reduce reactions to changing values within the current bar.
- Position size scales with account assets, market price, and contract value.
- Stop levels close positions after adverse price moves and prevent further orders on that bar.
- In-memory position tracking can speed backtests, but a live restart loses that tracking state.
Tags
From a private course collection; the original is not published.