Grand Trend Forecasting - A Simple And Original Approach Today we'll link time series forecasting with signal processing in order to provide an original and funny trend forecasting method, the post share lot of information, if you just want to see how to use the indicator then go to the section "Using The Indicator".
Time series forecasting is an area dealing with the prediction of future values of a series by using a specific model, the model is the main tool that is used for forecasting, and is often an expression based on a set of predictor terms and parameters, for example the linear regression (model) is a 1st order polynomial (expression) using 2 parameters and a predictor variable ax + b . Today we won't be using the linear regression nor the LSMA.
In time series analysis we can describe the time series with a model, in the case of the closing price a simple model could be as follows :
Price = Trend + Cycles + Noise
The variables of the model are the components, such model is additive since we add the component with each others, we should be familiar with each components of the model, the trend represent a simple long term variation of high amplitude, the cycles are periodic fluctuations centered around 0 of varying period and amplitude, the noise component represent shorter term irregular variations with mean 0.
As a trader we are mostly interested by the cycles and the trend, altho the cycles are relatively more technical to trade and can constitute parasitic fluctuations (think about retracements in a trend affecting your trend indicator, causing potential false signals).
If you are curious, in signal processing combining components has a specific name, "synthesis" , here we are dealing with additive synthesis, other type of synthesis are more specific to audio processing and are relatively more complex, but could be used in technical analysis.
So what to do with our components ? If we want to trade the trend, we should estimate right ? Estimating the trend component involve removing the cycle and noise component from the price, if you have read stuff about filters you should know where i'am going, yep, we should use filters, in the case of keeping the trend we can use a simple moving average of relatively high period, and here we go.
However the lag problem, which is recurrent, come back again, we end up with information easier to interpret (here the trend, which is a simple fluctuation such as a line or other smooth curve) at the cost of decision timing, that is unfortunate but as i said the information, here the moving average output, is relatively simple, and could be easily forecasted right ? If you plot a moving average of high period it would be easier for you to forecast its future values. And thats what we aim to do today, provide an estimate of the trend that should be easy to forecast, and should fit to the price relatively well in order to produce forecast that could determine the position of future closing prices observations.
Estimating And Forecasting The Trend
The parameter of the indicator dealing with the estimation of the trend is length , with higher values of length attenuating the cycle and noise component in the price, note however that high values of length can return a really long term trend unlike a simple moving average, so a small value of length, 14 for example can still produce relatively correct estimate of trend.
here length = 14.
The rough estimate of the trend is t in the code, and is an IIR filter, that is, it is based on recursion. Now i'll pass on the filter design explanation but in short, weights are constants, with higher weights allocated to the previous length values of the filter, you can see on the code that the first part of t is similar to an exponential moving average with :
t(n) = 0.9t(n-length) + 0.1*Price
However while the EMA only use the precedent value for the recursion, here we use the precedent length value, this would just output a noisy and really slow output, therefore in order to create a better fit we add : 0.9*(t(n-length) - t(n-2length)) , and this create the rough trend estimate that you can see in blue. On the parameters, 0.9 is used since it gives the best estimate in my opinion, higher values would create more periodic output and lower values would just create a rougher output.
The blue line still contain a residual of the cycle/noise component, this is why it is smoothed with a simple moving average of period length. If you are curious, a filter estimating the trend but still containing noisy fluctuations is called "Notch" filter, such filter would depending on the cutoff remove/attenuate mid term cyclic fluctuations while preserving the trend and the noise, its the opposite of a bandpass filter.
In order to forecast values, we simply sum our trend estimate with the trend estimate change with period equal to the forecasting horizon period, this is a really really simple forecasting method, but it can produce decent results, it can also allows the forecast to start from the last point of the trend estimate.
Using The Indicator
We explained the length parameter in the precedent section, src is the input series which the trend is estimated, forecast determine the forecasting horizon, recommend values for forecast should be equal to length, length/2 or length*2, altho i strongly recommend length.
here length and forecast are both equal to 14 .
The corrective parameter affect the trend estimate, it reduce the overshoot and can led to a curve that might fit better to the price.
The indicator with the non corrective version above, and the corrective one below.
The source parameter determine the source of the forecast, when "Noisy" is selected the source is the blue line, and produce a noisy forecast, when "Smooth" is selected the source is the moving average of t , this create a smoother forecast.
The width interval control...the width of the intervals, they can be seen above and under the forecast plot, they are constructed by adding/subtracting the forecast with the forecast moving average absolute error with respect to the price. Prediction intervals are often associated with a probability (determining the probability of future values being between the interval) here we can't determine such probability with accuracy, this require (i think) an analysis of the forecasting distribution as well as assumptions on the distribution of the forecasting error.
Finally it is possible to see historical forecasts, that is, forecasts previously generated by checking the "Show Historical Forecasts" option.
Examples
Good forecasts mostly occur when the price is close to the trend estimate, this include the following highlighted periods on AMD 15TF with default settings :
We can see the same thing at the end of EURUSD :
However we can't always obtain suitable fits, here it is isn't sufficient on BTCUSD :
We can see wide intervals, we could change length or use the corrective option to get better results, another option is to use a log scale.
We will end the examples with the log SPX, who posses a linear trend, so for example a linear model such as a linear regression would be really adapted, lets see how the indicator perform :
Not a great fit, we could try to use an higher length value and use "Smooth" :
Most recent fits are quite decent.
Conclusions
A forecasting indicator has been presented in this post. The indicator use an original approach toward estimating the trend component in the closing price. Of course i should have given statistics related to the forecasting error, however such analysis is worth doing with better methods and in more advanced environment allowing for optimization.
But we have learned some stuff related to signal processing as well as time series analysis, seeing a time series as the sum of various components is really helpful when it comes to make sense of chaotic and noisy series and is a basic topic in time series analysis.
You can see that in this new year i work harder on the visual of my indicators without trying to fall in the label addict trap, something that i wasn't really doing before, let me know what do you think of it.
Thanks for reading !
Prediction
Bitcoin Difficulty Model [aamonkey]This is a model to calculate Bitcoin price based on Difficulty.
How to calculate it:
BDM = (difficulty^0.51) * 0.002
For the difficulty, the daily average is used.
Confluence Zone Calculation for Support in Bullish TendsConfluence Zone Calculation for Support in Bullish Tends
(or Restance in bearish ones)
Ever wondered why sometimes the zag of an Elliot Wave zigzag is stopped after just a few points?
(Like in the given Chart where I draw a line for a typical zag action.)
It has often to do with confluence Zones. Most people think that the lower edge of a narrow range, repeated a few times, creates big support - confluence zones are stronger.
You can make them visible by getting fibonaccis from just one specific high to several different significant lows (for example the range lines mentioned above). The areas where significant lows and their fibos appear very close together are confluence zones. They can brake a falling price like a security net.
This script caluculates Confluence zones for you by using a second useful "secret": the secret that signifant lows test or create temporal rsi lows (vice-verse with highs).
The thicker (non-aqua clored)lines show actual lows, are corresponding with those rsi lows, the thinner are fibo lines deriving from them. (The white line stands for the high taken for the calculation.)
Note: Only those lines are valid which reach to the actual last bar.
Best practise is to let the script calculate,then redraw your lines of interest by hand and get rid of the rest of the spider web-like turmoil of lines by deleting the script from the chart.
Note further: I had to omit some calculations, because otherwise calculation time gets too long for TV and it stops with calculation Time out. (For your transparency I calculated all fibo codes but skipped some in "sline"-function; the number-suffix makes a jump when i omit a value ).
Note further further: Resistance confluence lines for bullish trends need a different script, because if you do it totally right vou in this case work from a single LOW of your interes t.
I hope it enriches your knowledge and is a help for your studies and tradings.
Feedback and Questions welcome
yoxxx
Triple MA 5-period forecast [Siem]This script calculates 3 MAs and forecasts where these MAs will be in the next 5 future periods.
Automatic mode - price will be based on current price ("flat") or an X-period linear regression ("linreg").
Manual mode - enter your own value('s): let's see where the MA's will be when your favourite equity all of a sudden hits 1 million tomorrow!
based on Triple MA Forecast by yatrader2 , idea by anthnyl
Morphed Sine WaveIntroduction
If you rescale a sine wave to the price you will need to correlate it with it in order to show good results, today i present a different method that does not involve correlation to "morph" a sine wave to the price in order to provide forecast's and highlight market periodic patterns.
Parameters
length control the period of the sine wave, power control the "morphing" amount, if you see for example that the results are going nuts try to increase power , if the results are just the price and the delayed price try to decrease power .
power = 1
power = 100
Those settings might be different depending on which market you are in.
Various Uses
You can do a lot of things with this indicator, use filters as source :
Use the indicator as source for oscillators in order to create cycles indicators :
And certainly many more things
Conclusion
I presented a way to morph a sine wave to the price i order to highlight cycles. You can use any function that return a value between -1 and 1 instead of sin , this can be a scaled rsi/stochastic or correlation coefficient, its up to you :)
If you need help don't hesitate to commend or pm me. I hope you will like the indicator and that it will inspire you to make great things.
Thanks for reading !
DepthHouse Exponential CandlesThis EMA Candles indicator use the price movement between two user selected Exponential Moving Averages to help determine the current trend.
As of release, there are 5 possible bar color outputs, all of which are shown in the legend above.
The Five Electable Color Outputs:
Uptrend; Strong Uptrend; Downtrend; Strong Downtrend; n/a
I hope you all enjoy!
Please leave your suggestions in the comments below!
Pivot Point Daily prediction bitcoin - by Simon-RoseThis is an additional Script to my recent Pivot Point indicator scripts which will show you the next days pivot points based on the actual price range.
This is useful if you are trading right before a new day and want to know how the next bdays pivot points may be placed.
If you have any questions or suggestions pls write me :)
Happy trading
Cheers
Daily Pivots:
Weekly Version:
Monthly Version:
HoltsMethodHolt's method (see: otexts.com)
Holt (1957) extended simple exponential smoothing to allow the forecasting of data with a trend.
This method involves a forecast equation and two smoothing equations (one for the level and one for the trend):
Forecast equation: ŷ = l + h * b
Level equation: l = alpha * y + (1 - alpha) * (l + b )
Trend equation: b = beta * (l - l ) + (1 - beta) * b
where h is a step forward or lookahead
Hull MA BarsThis indicator fill bars with color of HullMA + warning yellow bars, then trend reversing
RSI Correlation with future priceThis script measures the correlation of the hourly RSI of 24 hours ago with the difference of price between now and the price 24 hours ago. In other words, this is an indicator which measures the predictive power of the RSI.
Green means that the price is strongly correlated with the past RSI (which is the normal state when the market is flat and there is no news).
Red means that the price is inversely correlated with the past RSI.
The hourly RSI is a leading indicator which enables you to (sort of) see into the future. It shows you how the current price is, compared to the price 24 (or 48) hours into the future.
If the RSI is low, it means the current price is low compared to the future price, and if the RSI is high, it means the current price is high compared to the future price.
So the hourly RSI really correlates (in the way I described) to the price 24 hours in the future.
Except when it doesn't!!!
What happens when the correlation breaks (RED on this indicator)? Usually there are important news - a strong signal external to the chart. There are either economy at large news, or security-specific news.
Following a strong break of this RSI-future price correlation, some cash can be made by understanding what happened and playing the restoration of the RSI-price correlation.
Hull MA & Warning Zones & Buy/Sell ArrowsThis moving average, in contrast to the standard, shows a slowdown of the current trend - it draws additional zones of yellow color. These zones show a possible trend reversal by 1-2 bars earlier than the standard Hull moving average. Additionally, there are arrows to enter a position and the second is the same MA for another timeframe, which can be selected in the settings.
Bull Bear Divergence IndicatorThe script is written for Constance Brown-like anayis with divergence signals between price and indicator (i.e. stock close / RSI divergence)
Note: Though the example here with NVDA shows good reversal predictions, best results generally are optained with un-normalized indicators and oscilators like CB#s comosite index.
(For Trading view written by LazyBear.) I use two different lines: an indi high line for baerish, and an indi low line for bullish divergences.
The script only shows divergences to pivot pairs next to each other, not between actual pivot and those "a few pivots ago"
For individual work, chose your indicator and replace rsi in line 10 with it, anything else is auto. Sript bottom: optional comparison lines addable.
Linear ExtrapolationBasic extrapolator for forecast a time-series, all forecasts are mades length periods ahead.
This is not a estimation of the exact price
This should only be used for forecasting direction, dont expect the price to be at the same value of its forecast.
Bias, Mean absolute error, Mean percentage error...etc look useless here, its better to use correlation as a accuracy measurement.
Correlation(Forecast ,close,period)
Rescaling for a better forecast ?
Transforming a non-stationary signal to a stationary signal can increase the forecasting accuracy, this can be done by detrending. Here is a list of somes detrending methods:
Auto-Bias : price - price
Mean-Bias : price - price moving average
Log transform : log(price/price moving average)
Correlation : correlation(price,n,period)
Twiggs Money Flow_LB [SwetSwet]The modified indicator Twiggs Money Flow more convenient. The critical value is colored in green or red.