A new machine learning indicator offers traders a multi-horizon price forecast using a Random Forest model, marking a significant advancement in algorithmic trading tools. Developed with RandomForestLib, the first open-source Random Forest library for Pine Script, this tool enables users to build, train, and deploy regression-based ensemble models directly within the Pine Script environment. Its capability to generate forward-looking price predictions comes with statistically grounded prediction intervals, enhancing decision-making in volatile markets.
The model forecasts percentage price changes for the next 1 to 20 bars simultaneously, visualizing this predicted path as a polyline on price charts. The fan-shaped prediction intervals, which widen over longer time horizons, reflect the model’s increasing uncertainty in its forecasts. This feature distinguishes it from traditional single-step models that only predict the next immediate bar.
At the core of the model are eight engineered technical features, including the Relative Strength Index (RSI), Average True Range (ATR) as a percentage of price, and the Commodity Channel Index (CCI). Other features include volume ratios relative to their 20-bar simple moving average (SMA) and price positions concerning a 50-bar SMA. The model also incorporates momentum indicators and Bollinger Band width to enhance its predictive capabilities.
The multi-horizon forecasting approach enables the model to train separate regression targets for different time frames, from H1 to H20. Each of these horizons predicts percentage price changes from the current bar, creating an entire forward price trajectory rather than a single-point estimate. This comprehensive outlook on price movements provides traders with a clearer view of potential market shifts.
Prediction intervals are calculated using the Out-of-Bag (OOB) residual method, as detailed in academic research by Wager et al. in 2014. During the training process, each sample’s OOB prediction error is documented, and the standard deviation of these residuals is used to estimate forecast uncertainty. The intervals—set at 90% and 95%—indicate the range within which future prices are expected to fall, with the width of these intervals increasing at longer horizons. For instance, the 90% prediction interval is calculated as ±1.645 times the OOB residual standard deviation, while the 95% interval is ±1.960 times that same measure.
Another notable aspect of the model is its non-repainting design. All training and inference operations occur exclusively on the final bar, ensuring that forecasts remain static and reflective of real-time market conditions. Traders can have confidence that what they see on their charts represents genuine predictive output without adjustments after the fact.
A user-friendly dashboard accompanies the indicator, displaying key metrics such as the predicted market direction, Out-of-Bag R-squared values, and the current ensemble configuration. It provides crucial insights into the predicted percentage changes at 5, 10, and 20-bar horizons, as well as the total width of the prediction interval at the furthest horizon.
Users can customize several parameters, including the number of trees in the ensemble and the maximum depth of the trees, to optimize the model according to their trading strategies. The default settings allow for a balance between performance and computational efficiency, while an option to toggle the visibility of prediction interval bands adds further flexibility.
In summary, this new machine learning indicator harnesses the power of Random Forest algorithms to offer traders a sophisticated tool for forecasting price movements over multiple time horizons. By allowing for a comprehensive visualization of price trajectories and incorporating prediction intervals that accurately reflect uncertainty, it positions itself as a valuable resource for both novice and experienced traders. As the trading landscape continues to evolve with technological advancements, tools like these may play a pivotal role in shaping future market strategies.
See also
AI Study Reveals Generated Faces Indistinguishable from Real Photos, Erodes Trust in Visual Media
Gen AI Revolutionizes Market Research, Transforming $140B Industry Dynamics
Researchers Unlock Light-Based AI Operations for Significant Energy Efficiency Gains
Tempus AI Reports $334M Earnings Surge, Unveils Lymphoma Research Partnership
Iaroslav Argunov Reveals Big Data Methodology Boosting Construction Profits by Billions


















































