
Can you forecast future price trends?
In a previous newsletter, we used VectorBT PRO (VBT) to detect price patterns. VBT can also forecast these price segments into the future!
Having a high-confidence estimate of where the price of an asset may move in the future can help with risk management and real-time analysis.
Are you ready to learn how?
Let’s go!
Forecast future price trends (with projections)
Imports and set up
Given the self-contained design of VBT, a single import is enough for the analysis.
Let's define a set of variables for our analysis and grab data from Yahoo Finance.
Find and plot projections
Let's write a function that analyzes the most recent price trend and employs it as a pattern to identify similar price movements in historical data
This pattern recognition function will focus exclusively on segments of price history having a comparable percentage change from their respective starting points.
We identified 14 price segments that closely resemble the latest price trend.
The function that extracts the price data immediately after each segment and plots these as extensions of the price trend. The result is a series of price projections.

As we can see, similar price movements have historically branched into many paths.
For a statistically robust forecast, we display the confidence bands around the projections, with 60% of these projections falling between the upper and lower bands
Generate an animated GIF
Lastly, we will generate an animated GIF that iterates through a specified range of bars, applying the procedure to each bar within that range.
The result is an illustrated depiction of the real time price forecasts.

Next steps
There are two action items you can follow to take advantage of this powerful forecasting feature. First, is use it to set limit orders and stop losses during live trading.
The second is to generate a backtest using these price predictions in your strategy.