Steversteves

ARIMA Moving Average and Forecaster [SS]

Steversteves מעודכן   
Finally releasing this. This took months, over 3 months to be precise, to figure out, code and troubleshoot! I honestly was going to give up on this project, but I finally got it to actually work fairly reliably. So hopefully you like it!

This is a very basic ARIMA modeler. It can do the following:

1. Provide you with an ARIMA based Moving Average;
2. Provide you with a standard error band;
3. Auto-select a lag length for assessment based on stationarity;
3. Provide you with the option of extending the error range by a user selected amount of standard deviations; and
4. Forecasting and plotting the forecast on the chart.

I will go over each function individually, but before I do, I think its important to talk a bit about what an ARIMA Model is and does:

ARIMA stands for AutoRegressive Integrated Moving Average and is an approach to modeling and time series forecasting. In simple terms, it combines autoregressive (AR) and moving average (MA) components to capture the underlying patterns in a time series data. The "AutoRegressive" part accounts for the relationship between an observation and its previous values, while the "Moving Average" part considers the relationship between an observation and a residual error from past observations. The "Integrated" component involves differencing the time series to make it stationary, which aids in stabilizing the model. ARIMA models help predict future values based on patterns observed in historical data, making them useful for forecasting in various fields such as economics, finance, and weather prediction.

The benefits to ARIMA is it will forecast based on the current trend, but it also provides for both the up and down scenario of the trend (i.e., if we are in a downtrend, what it would look like and what values we could expect if the trend reverses and vice versa). All of this is within the scope of this indicator, believe it or not!

If you would like more information on ARIMA, you can check out my educational post about it here:

Alrighty, now for the indicator functions.

ARIMA Moving Average and Standard Error Band


The ARIMA moving average is very simple, it takes the SMA of the current trend, lags it and plots out the lagged SMA. You can toggle the auto-select lag on, or you can pick your own lag manually. The above image is an auto-selected lag, but if we manually lag it by 5, this is what it looks like:


Its simply a lagged average of the 5 SMA (that is essentially how ARIMA works, by creating a moving average and lagging the moving average).

There are some implications to selecting a lag factor when it comes to forecasting, but I will cover this in the forecasting section. But I do want to make mention, you can use the ARIMA moving average in lieu of other moving averages. The advantage to doing this is it will be able to plot out the error bands. For example, if we wanted to get an ARIMA MA of the 200 SMA, we can toggle on the error bands and this is what we get:


Or the 50 MA:


NOTE: You ABSOLUTELY SHOULD NEVER use more than a lag of 4 or 5 for Forecasting (will be discussed later).

Auto-Select Lag

The indicator pulls the ARIMA modeler framework from my Forecasting library and pulls the stationarity assessment from my SPTS library. When you are doing an ARIMA model for forecasting, we need to ensure the data is stationary. Thus, if you want to forecast out the current trend, its highly recommended you select the "Auto Determine Lag Length" to find the most appropriate lag and forecast accordingly.

You can, however, chose your own lag order (model order), but this should never be above 4 or 5.

You should never select a lag of more than 5 because you are introducing too much "trendiness" into the equation, and you will get astronomical readings. ARIMA models never generally exceed a lag of 3 or 4 at most, as they are supposed be stationary and de-trended.


Extending by Standard Deviation

There is an option to select a standard deviation extension band. This is helpful for active day trading. Here is NIO extended by 2 standard deviations:


General suggestion is to only extend by 2 standard deviations and this is sufficient for most stocks.

Forecasting

The hallmark of an ARIMA model is the ability to use it for forecasting. Thus, the forecasting feature is a large portion of this indicator. You can see it displayed in the main chart above, but let's show some other examples:

NIO on the 1 hour:


TSLA on the 4 hour:


You can also display a forecasting table:


The result row shows the most likely, conservative, price at each time increment.
The Upper Confidence and Lower Confidence show what the trend would look like if it continued up or down at the current rate and the 95% confidence intervals show the values that the true source is likely to fall between at various increments in time with a 95% confidence (i.e. 95% probability that it should fall between these levels at period xyz assuming normal distribution).

The important levels, in my opinion, are the upper and lower confidence levels. These show you the current rate of decline or increase that the stock is expecting and what the trend would look like with a continuation or a reversal. This is ARIMA's biggest strength, as it has the ability to plot both outcomes assuming the current trend rate and time remains constant.


And that is the indicator! ARIMA is a bit of a complex process, but its a very powerful tool when used properly!

Troubleshooting:

One thing of note. Sometimes when autoselecting a length for forecasting, if there has been a heavy trend in one direction, you will not get the upper or lower confidence levels because of the lack of any up or down movement. In this case, manually select a lag of 3 to 5 to correct for this.

Let me know if you have any questions below and safe trades everyone!

הערות שחרור:
Just had to fix a spelling error and default lag value as it was annoying me.

But also just wanted to respond to a question, as you can't anchor this indicator in the past, if you want to use it for forecasting weekly levels or intraday, draw out the trendlines and then just mute the indicator. Here are some sample forecasts for this week:

SPY:

NQ:


NVDA

Its surpassed my own expectations so I do hope you enjoy it and find it helpful!

Safe trades everyone!

Premium indicators and content have launched! Get access at: www.patreon.com/steversteves
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?