Posts

Showing posts from November, 2025
Image
  A SQL Model for Buying and Selling Tickers Based on Historical Prices from Tiingo and EMAs This Security Trading Analytics blog exists to illustrate analytical approaches for trading securities.  This post describes and demonstrates T-SQL code for choosing buy and sell dates for four securities based on raw close prices downloaded with PowerShell and EMA value sets computed in SQL Server. The model chooses to buy a ticker share when the security price concurrently rises above its long-term and short-term price trends.  The model chooses to sell an owned  ticker share when the security price falls below a short-term price trend that is above the one used to select a buy date.  Recognize that the model is just one hypothesis among many for choosing buy and sell dates.  Within the context of this post, the main objective of implementing the model is to establish a framework for backtesting the model returns.  A follow-up post to this one will illustrat...