Skip to content
All library documents

Counting Trading Days Since a Condition Was Met

Article BigQuant

Summary

This short forum exchange asks how to count trading days since a condition last became true. Its example starts counting on the session after the trigger: if the condition occurs on one date, the next trading day returns one and the following session returns two. The suggested approach is to store the position where the condition occurred, track the most recent trigger date, and update the count as data advances.

The post offers a basic implementation idea rather than a complete algorithm or code walkthrough. It does not specify how to handle repeated triggers, missing observations, calendar dates without trading, or whether the trigger day itself should count. Those details must be defined to fit the intended trading rule; the example clarifies only the desired next-session counting convention.

Key ideas

  • Store the position or date of the most recent condition trigger.
  • Increment the count as each subsequent trading session passes.
  • The example assigns a count of one to the first trading day after the trigger.
  • Repeated triggers and non-trading calendar dates require explicit handling.

Tags

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