Skip to content
All library documents

Session Gap Fill Entries with ATR Trailing Stops

Article Strategy library · Author: Shivam_Mandrai

Summary

This script trades reversals toward the prior session’s final close after a sufficiently large opening gap. It records the first bar’s open and the previous session’s close, then checks whether the gap meets a configurable percentage threshold. For an upward gap, it enters long when a later bar dips below the prior close and finishes above it; for a downward gap, it enters short after price moves above and closes back below that reference. Signals are accepted only on confirmed bars outside the session’s first and last bars, and entries require the strategy to have no open position.

An ATR-based trailing stop is initialized from the average entry price and then adjusted in the favorable direction using the close and a volatility multiple. The script shows the stop while a position is active and resets it when flat. The document provides implementation logic and default strategy settings, but no performance results or instrument-specific evaluation. Gap thresholds, session definitions, ATR settings, transaction costs, and execution assumptions can materially affect outcomes; the trailing stop also does not establish that gap reversals will occur reliably.

Key ideas

  • The strategy compares the opening price with the previous session’s last close and filters gaps by a configurable percentage threshold.
  • A long signal requires an upward gap followed by a bar that crosses below and closes above the prior close.
  • A short signal requires a downward gap followed by a bar that crosses above and closes below the prior close.
  • Confirmed signals are entered only while flat and outside the session’s first and last bars.
  • An ATR-based stop trails in the favorable direction and resets after the position closes.

Tags

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