Machine Learning: ARIMA + SARIMA
May 5, 2025

The Machine Learning: ARIMA + SARIMA indicator provides advanced statistical forecasting by utilizing autoregressive models to project future price movements. It automatically differences market data to achieve stationarity and adjusts parameters based on current market conditions to provide predictive insights into potential trends and seasonal patterns.
Usage
The Usage section describes how the script can be used to interpret market behavior and forecast future outcomes.
- Model Selection: Users can choose between two primary models:
- ARIMA: Optimized for identifying general trends and directions.
- SARIMA: Incorporates seasonality, making it more effective at capturing recurring historical patterns.
- Directional Visualization: By enabling "Show Historic Prediction," the script displays the direction of previous forecasts. Green indicates a predicted upward movement, while red indicates a predicted downward movement.
- Accuracy Metrics: The indicator tracks performance via RMSE% and MAPE (10-day moving averages). These error metrics compare observed data with predicted data. Values below 8% generally suggest higher reliability. Note that higher timeframes often show higher error rates due to trending behavior vs. the mean-reverting nature of these models.
- Training Period: The training period is best kept between 20 and 80 (defaulting to 50). Using excessively high values may introduce significant lag and reduce the responsiveness of the machine learning model.
Details
The script implements the Autoregressive Integrated Moving Average (ARIMA) and its Seasonal counterpart (SARIMA) using Pine Script.
- Autoregression (AR): Finds relationships between observed data and lagged observations to recognize patterns.
- Integrated (I): Uses differencing to remove non-stationary elements (like trends) from the data, making it more predictable for the model.
- Moving Average (MA): Creates a dependency between an observation and a residual error from a moving average model applied to lagged observations.
- Seasonality (SARIMA only): Adds parameters to model recurring cycles (Seasonal Period) to account for time-dependent patterns often found in financial markets.
Settings
The settings are categorized into general model parameters and specific ARIMA/SARIMA configurations:
- Model Type: Selects between ARIMA (directional focus) or SARIMA (pattern focus).
- Forecast Length: Sets the number of bars into the future the model will predict (max 50).
- Training Period: Determines how many historical data points are used to train the model.
- Memory: Adjusts the weight given to older data (Low, High, or Auto).
- AR Order (p): Sets the Autoregressive order; higher values improve recognition but risk overfitting.
- Differencing (d): Sets the order of differencing to make data stationary.
- MA Order (q): Sets the Moving Average order to account for recent error sensitivity.
- Seasonal Period (s): Defines the number of bars in a seasonal cycle.
- Seasonal AR Order (P): Adjusts the seasonal autoregressive complexity.
- Seasonal Differencing (D): Applies differencing to seasonal cycles.
- Seasonal MA Order (Q): Models error terms specifically across different seasons.
- Show Historic Prediction: Toggles the visibility of previous directional forecasts on the chart.
FAQ
How do I interpret the RMSE% and MAPE values? These are error metrics that indicate the accuracy of the forecast. Lower percentages mean the model's predictions are closer to the actual price. It is generally recommended to look for values below 8% for higher confidence.
Why does the forecast look different on higher timeframes? Higher timeframes tend to trend more aggressively, while ARIMA/SARIMA models are partially mean-reverting. This can lead to larger deviations between predictions and actual price action on daily or weekly charts compared to intraday charts.
How do I get access to Machine Learning: ARIMA + SARIMA? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Unlock Unlimited Access to the LuxAlgo Library
Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

