DEV Community

Jungle Sven
Jungle Sven

Posted on

Using Standard Deviation for Signals and Spreads

I'll show you how to use standard deviation to attempt to predict price reversals. As a bonus, we'll measure volatility ranges to place orders at optimal distances from the mean price.

Image description

Signals

We'll try to predict price reversals from peak values to the mean using standard deviation. The idea is that the market often returns to mean values after "overheating." These peak values correspond to peak standard deviation values.

Of course, this alone isn't enough to reliably predict price direction. So, we'll use two filters.

  1. First, the standard deviation must decrease to avoid shorting during continued growth and buying during declines.
  2. Second, the current price must be below the mean for buying and above it for selling.

Volatility Levels

We need to know the current market volatility to adjust our targets, stops, and more.

Typically, volatile periods form clusters. New information enters the market, traders use it, there's a price discovery process, and then the market calms down again.

We'll take data from several days and calculate boundaries for five standard deviation levels. Then, we'll plot a chart to see the results.

This is similar to the work I recently shared. However, in that case, I worked with tick data, and this time, I used candlesticks. Link to previous work

You can access the complete code here.

twitter

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

Image of Timescale

PostgreSQL for Agentic AI — Build Autonomous Apps on One Stack 1️⃣

pgai turns PostgreSQL into an AI-native database for building RAG pipelines and intelligent agents. Run vector search, embeddings, and LLMs—all in SQL

Build Today

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay