Skip to content
All library documents

Estimating Intraday Buy and Sell Hours with Circular Averages

Article TradingView scripts

Summary

This strategy estimates recurring times of day associated with favorable buying and selling indicator readings. It assigns each bar’s hour to a position on a 24-hour circle, weights its sine and cosine components by an indicator, and uses an atan2-based angle to recover an average hour. This circular mean avoids the wraparound error of ordinary arithmetic averaging, where late-night and early-morning times can appear far apart. Separate calculations produce candidate buy and sell hours, and the strategy places orders when the current hour matches the rounded estimate.

The script uses RSI and money-flow readings, with inverted-price inputs for the sell calculation, and allows the user to choose a timezone and data source. The author describes the method as tested primarily on BTC/USDT and explains that the selected hour represents an average of past indicator changes, not a guaranteed profitable time. No performance statistics or out-of-sample validation are provided; results may vary by instrument, timeframe, timezone, and chosen indicator.

Key ideas

  • A circular mean represents hours as angles to handle the 24-hour boundary correctly.
  • Indicator-weighted sine and cosine averages are converted back into estimated buy and sell hours.
  • The strategy submits orders when the current hour matches a rounded estimated hour.
  • The estimated hour summarizes historical indicator behavior and does not guarantee a favorable trade.

Tags

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