Skip to content
All library documents

Reusable Daily Alarm Clocks for Scheduled Strategy Actions

Article FMZ digest · Author: 善

Summary

This document shows how to encapsulate time-based triggers in reusable alarm-clock objects for trading strategies. Each object stores a trigger hour and minute, checks the current clock, and returns true once the scheduled minute has arrived. A per-day flag prevents repeated triggers, and the flag resets when the calendar day changes. Separate objects can schedule different actions independently.

The example uses a moving-average crossover to choose a position near the market open and closes positions before the afternoon session ends. JavaScript and Python implementations are included, along with backtest screenshots described as showing the scheduled openings and closings. The examples are instructional rather than evidence of trading profitability. The note also cautions that a backtest using overly large K-line intervals may skip the trigger time. It does not address exchange time zones, holidays, missed data, or scheduling behavior when the strategy process is interrupted.

Key ideas

  • An alarm object stores a daily trigger time and reports the trigger only once per day.
  • Separate alarm instances can control different scheduled actions without sharing trigger state.
  • The example schedules moving-average-based entries at the open and position closure before the close.
  • Large backtest bar intervals may skip scheduled trigger times.
  • The examples demonstrate time control, not strategy profitability or robust scheduling across market calendars.

Tags

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