Leavitt Convolution [CC]The Leavitt Convolution indicator was created by Jay Leavitt (Stocks and Commodities Oct 2019, page 11), who is most well known for creating the Volume-Weighted Average Price indicator. This indicator is very similar to my Leavitt Projection script and I forgot to mention that both of these indicators are actually predictive moving averages. The Leavitt Convolution indicator doubles down on this idea by creating a prediction of the Leavitt Projection which is another prediction for the next bar. Obviously this means that it isn't always correct in its predictions but it does a very good job at predicting big trend changes before they happen. The recommended strategy for how to trade with these indicators is to plot a fast version and a slow version and go long when the fast version crosses over the slow version or to go short when the fast version crosses under the slow version. I have color coded the lines to turn light green for a normal buy signal or dark green for a strong buy signal and light red for a normal sell signal, and dark red for a strong sell signal.
This is another indicator in a series that I'm publishing to fulfill a special request from @ashok1961 so let me know if you ever have any special requests for me.
Forecasting
VuManChu Cipher A + B&S SignalsОбъединены два скрипта в один VuManChu Cipher A и VuManChu Swing Free.
FOMC & CPI DatesThis indicator plots vertical lines at the scheduled times of US Federal Reserve's FOMC Meeting Dates.
Data is based on U.S. Federal Open Market Committee (FOMC) Meeting Minutes
Leavitt Projection [CC]The Leavitt Projection indicator was created by Jay Leavitt (Stocks and Commodities Oct 2019, page 11), who is most well known for creating the Volume-Weighted Average Price indicator. This indicator is very simple but is also the building block of many other indicators, so I'm starting with the publication of this one. Since this is the first in a series I will be publishing, keep in mind that the concepts introduced in this script will be the same across the entire series. The recommended strategy for how to trade with these indicators is to plot a fast version and a slow version and go long when the fast version crosses over the slow version or to go short when the fast version crosses under the slow version. I have color coded the lines to turn light green for a normal buy signal or dark green for a strong buy signal and light red for a normal sell signal, and dark red for a strong sell signal.
I know many of you have wondered where I have been, and my personal life has become super hectic. I was recently hired full-time by TradingView, and my wife is pregnant with twins, and she is due in a few months. I will do my absolute best to get back to posting scripts regularly, but I will post a bunch today in the meantime to fulfill a special request from one of my loyal followers (@ashok1961).
Adaptive Rebound Line (ARL)The Adaptive Rebound Line (ARL) focuses on the rebound of price action according to the trend.
While it does not focus on showing the trend, it does help in anticipating price rebounds.
It achieves this by adapting quickly and by reducing lag.
It is recommended to use this with a trend-identifying indicator.
It was inspired by the Hull Moving Average and the KAMA.
Additional indicator show in the chart is Tide Finder Plus .
Itakura-Saito Autoregressive Extrapolation of Price [Loxx]The Itakura–Saito distance is a Bregman divergence generated by minus the logarithmic function, but is not a true metric since it is not symmetric and it does not fulfil triangle inequality.
In Non-negative matrix factorization, the Itakura-Saito divergence can be used as a measure of the quality of the factorization: this implies a meaningful statistical model of the components and can be solved through an iterative method.
The Itakura-Saito distance is the Bregman divergence associated with the Gamma exponential family where the information divergence of one distribution in the family from another element in the family is given by the Itakura-Saito divergence of the mean value of the first distribution from the mean value of the second distribution.
Fed LiquidityFed liquidity model based on #MaxJAnderson's work. Incorporates the Treasury General Account, Reverse Repo and Fed balance sheet to determine how much "net liquidity" is available to markets. Very much a beta version.
EmirindicatorLook at the data while at the level you entered. The line below where you entered should be your Stop Loss level. The first line above it represents that you need to bring your Stop Loss level to your entry level and take some profit if you want. The top line is the sales level recommended by the program.
HPK Crash IndicatorFrom Hari P. Krishnan's book, The Second Leg Down: Strategies for Profiting after a Market Sell-Off :
"We start by specifying the year on year (YoY) change in the index. Next, we calculate the 5 year trailing Z score of the YoY returns. We also calculate the 5 year trailing Z score of 1 month historical volatility for the index, using daily returns. Our crisis warning indicator flashes if both Z scores are above 2. In other words, recent price increases and current volatility need to be at least 2 standard deviations above normal.
It can be seen that this basic implementation is reasonably effective, accepting that the effective sample set is small. A false signal is given in mid-2006, but the signal is quickly washed away. The remaining signals occur fairly close to the point of collapse. The idea that elevated volatility is predictive of danger is not new and underpins many asset allocation schemes. However, Sornette deserves credit for moving away from a largely valuation-based approach to predicting crises to one that relies upon price action itself."
Faytterro EstimatorWhat is Faytterro Estimator?
This indicator is an advanced moving average.
What it does?
This indicator is both a moving average and at the same time, it predicts the future values that the price may take based on the values it has taken before.
How it does it?
takes the weighted average of data of the selected length (reducing the weight from the middle to the ends). then draws a parabola through the last three values, creating a predicted line.
How to use it?
it is simple to use. You can use it both as a regression to review past prices, and to predict the future value of a price. uptrends are in green and downtrends are in red. color change indicates a possible trend change.
HTC_Bollinger_Band_Strategy_By_CorbachoEste indicador te da la visión del mercado y sus posibles rebotes con unas bandas de bollinger a 3 dispersiones tipicas. Añadiendo al grafico la SMA200 podemos ver si operamos a favor o en contra de la tendencia
Chervolinos-Wave-PM-ForecastThe Wave PM (Whistler Active Volatility Energy – Price Mass) indicator is an oscillator described in Mark Whistler's book, Volatility Illuminated.
The Wave PM is specifically designed to help read volatility cycles. When we visualize volatility cycles as a chart, we can get a clear view of the market volatility phases in multiple time frames. This indicator forms an arithmetic mean over 30 observed periods. Traders can thus get a better insight into "potential" volatility from up to pent-up energy, the different zones give strong help to predict future price developments.
Possible interpretation patterns:
You are at the end of a long uptrend and you want to know if the price is going to go down, if the indicator shows red and the value is above 25, it is likely to do so.
You're in a downtrend and there's a bit of a recovery phase, so you might be wondering if it's going to continue when the indicator shows green. It would go further with yellow, but with green it can be assumed that it is going down rapidly.
Special thanks to sourcey who programmed the 3D Wave-PM.
This variant of sourcey looks very nice, but was too confusing for me. In order to get a strong overview, forming an arithmetic mean is very useful.
I hope you and the Mods like my version
Best regards, Chervolino
Pivot Parallel Channel by [livetrend]This script draws parallel channels using pivot points for trend analysis.
Script draws maximum 4 parallel channels if suitable up or down trend already exists on the chart according to chosen Pivot Length and Multiplier.
You can change Multiplier to draw Higher Time Frame Channels.
Good luck!
Blockchain Fundamentals: 200 Week MA Heatmap [CR]Blockchain Fundamentals: 200 Week MA Heatmap
This is released as a thank you to all my followers who pushed me over the 600 follower mark on twitter. Thanks to all you Kingz and Queenz out there who made it happen. <3
Indicator Overview
In each of its major market cycles, Bitcoin's price historically bottoms out around the 200 week moving average.
This indicator uses a color heatmap based on the % increases of that 200 week moving average. Depending on the rolling cumulative 4 week percent delta of the 200 week moving average, a color is assigned to the price chart. This method clearly highlights the market cycles of bitcoin and can be extremely helpful to use in your forecasts.
How It Can Be Used
The long term Bitcoin investor can monitor the monthly color changes. Historically, when we see orange and red dots assigned to the price chart, this has been a good time to sell Bitcoin as the market overheats. Periods where the price dots are purple and close to the 200 week MA have historically been good times to buy.
Bitcoin Price Prediction Using This Tool
If you are looking to predict the price of Bitcoin or forecast where it may go in the future, the 200WMA heatmap can be a useful tool as it shows on a historical basis whether the current price is overextending (red dots) and may need to cool down. It can also show when Bitcoin price may be good value on a historical basis. This can be when the dots on the chart are purple or blue.
Over more than ten years, $BTC has spent very little time below the 200 week moving average which is also worth noting when thinking about price predictions for Bitcoin or a Bitcoin price forecast.
Notes
1.) If you do not want to view the legend do the following: Indicator options > Style tab > Uncheck "Tables"
2.) I use my custom function to get around the limited historical data for bitcoin. You can check out the explanation of it here:
Gann Square of 144This indicator will create lines on the chart based on W.D. Gann's Square of 144. All the inputs will be detailed below
Why create this indicator?
I didn't find it on Tradingview (at least with open source). But the main reason is to study the strategy and be able to draw it fast. Manually drawing the square is not hard, but moving all together to the right spots and scale was time-consuming.
It has a lot of inputs...
Yes, each square point divisible by 6 has information with some options, so the user can create any configuration he wants. Also, it has the advantage of having the square built in seconds and adjusting itself on each new calculation.
About the inputs
Starting Date
This input will be used when the "Set Upper/Lower Prices and Start Bar Automatically" checkbox is not selected. The indicator will calculate all the line locations on the chart using the selected start date. When selecting this input, change the Manual Max and Min Prices to the better calculation
Manual Max/Min Price
This input will be used when the "Set Upper/Lower Prices and Start Bar Automatically" checkbox is not selected. The indicator will calculate all the line's locations on the chart using these prices
Set Upper/Lower Prices and Start Bar Automatically
Selects if the starting date will be automatically selected by the system or based on the input data. When it's set, the indicator will use the most recent bar as the middle point of the square, using the higher price as the Upper Price and the lowest price as the Lower Price in the latest 72 bars (or more based on the Candles Per Division parameter)
Update at a new bar
When this option is market, the indicator will update all created lines to match the new bar position, together with all the possible new Upper/Lower prices. Let it unchecked to watch the progression of the price while the square remains fixed in the chart.
Top X-Axis
When checked, it will display the labels on the Top of the square
Bottom X-Axis
When checked, it will display the labels on the Bottom of the square
Left X-Axis
When checked, it will display the labels on the left of the square
Right X-Axis
When checked, it will display the labels on the right of the square
Show Prices on the Right Y-Axis
When checked, it will display the prices together with the labels on the right of the square
Show Vertical Divisions
Show the lines that will divide the square into 9 equal parts
Show Extra Lines
Show unique lines that will come from the Top and bottom middle of the square, connecting the center to the 36 and 108 levels
Show Grid
When selected, it will display a grid in the square
Line Patterns
A selector with some options of built-in lines configuration. When any option besides None is selected, it will override the lines inputs below
Numbers Color
Select the color of each number on the Axis
Vertical Lines Color
Select the color of the vertical lines
Grid Color
Select the grid line color
Connections from corners to N
Each corner is represented by 2 characters, so they all fit in a single line
It will indicate where the line starts and where it ends
┏ ↓ = Top Left to Bottom
┏ → = Top Left to Right
┗ ↑ = Bottom Left to Top
┗ → = Bottom Left to Right
┓ ← = Top Right to Left
┓ ↓ = Top Right to Bottom
┛ ← = Bottom Right to Left
┛ ↑ = Bottom Right to Top
Besides selecting what line will be created, it's possible to select the color, the style, and the extension
How to use this indicator
When you dig into Gann's books for more information about the square of 144, you find that it was part of his setup with multiple indicators (technical and fundamental, and astrological). It is not a "one indicator" setup, so it's hard to say that you will find entries, exits, stop loss, and take profit in this. Still, it will help see trendiness, support, and resistance levels.
Mixing this with other indicators is probably a good idea, but some may find this indicator the only one needed.
Some aspects of the square
The end of the square is important, so where it starts is crucial. The end is important because it is where the price and time expire. The other parts of the square are defined based on their start and end, so placing them right is essential.
So, where to set the start of the square?
The last major low is the most indicated. The minimum price will be the lowest, and the max price will be the last major Top. Note that the indicator uses 1 candle on each point.
After finding the start, the minimum, and the maximum prices for the square, it will draw all lines. Another essential part of the square is The Midpoint.
The midpoint is the most crucial part of the square and is the best way to see if you positioned the square correctly. When the price is inside the square, using the starting candle as the start, a second higher low or a lower high occurs in that spot. When using the Vertical lines in the indicator, it's the middle square inside Gann's square.
The other divisions will be opposing each other most of the time. So if the price is rising in the 1/3 of the square, it's common to see the price fall in the 3/3 of the square.
More information about these aspects here
Considerations
This indicator was meant for price targets and a time calculator for possible support/resistances in the chart. It was created by William Delbert Gann and was part of his setup for trading almost a century ago. The lines will form geometric figures, which Gann used with high accuracy to predict tops/bottoms and when they would occur.
Fed Funds Rate ProjectionsThis script makes projections via drawing boxes based upon changes in the fed funds rate (FRED:EFFR).
It works by turning the change in the fed funds rate into a user defined percentage (using a multiplier, by default a 1% rate of change implies a 10% change in the chart) and then drawing a box that distance away depending on the direction of the rate of change.
The size of the multiplier should depend on the duration of the asset which this is being applied to, for example, a long duration asset such as a high beta growth stock should use a larger multiplier.
SKYtrend Bruteforce Open Source✨SKYtrend Bruteforce Now Open Source✨
📌This indicator analyzes the trend and calls Long/Short which is fully custom to fit your style of trading.
📌Custom Take Profit Levels currently have 3 TP levels for Long and Short you can decide which % each TP will be in settings.
📌2 Custom Stoploss levels. For Long or Short. Can Enable or Disable either.
📌Can set alert For Long, Short , TP Long 1-3, TP Short 1-3, SL 1-2
📌Has built in ichimoku cloud
If you like it, like it. :)
VIX - SKEW DivergenceThe CBOE VIX is a well-known index representing market expectations for volatility over the next 30 days.
The CBOE SKEW is an index reflecting the perceived tail risk over the next 30 days.
When the SKEW rises over a certain level (~140/150), that means investors are hedging their exposure with options, because they are worried about an incoming market crash or a "black swan". If that happens when the VIX is very low and apparently there is no uncertainty, this can warn of a sudden change in direction of the market. You will see for yourself that an increasing divergence often anticipates a sharp fall of leading stock indexes, usually within two to four months.
This is probably not very relevant for the short-term trader but mid/long-term traders and market analysts may find it useful to clearly visualize the extent of the distance between the VIX and the SKEW. For that reason, I wrote this highly customizable script with which you can plot the two indexes and fill the space within them with a color gradient to highlight the maximum and minimum divergence. Additionally, you can fill the beneath VIX area with four different colors. It is also possible to plot the divergence value itself, so if you want you can draw trendlines and support/resistance levels on it.
Please note that the divergence per se doesn't predict anything and it's meant to be used synergistically with other technical analysis tools.
More informations here:
www.cboe.com
www.cboe.com
Rollover LTEThis indicator shows where price needs to be and when in order to cause the 20-sma and 50-sma moving averages to change directions. A change in direction requires the slope of a moving average to change from negative to positive or from positive to negative. When a moving average changes direction, it can be said that it has “rolled over” or “rolled up,” with the latter only applying if slope went from negative to positive.
Theory:
In order to solve for the price of the current bar that will cause the moving average to roll up, the slope from the previous bar’s average to the current bar’s average must be set equal to zero which is to say that the averages must be the same.
For the 20-sma, the equation simply stated in words is as follows:
Current MA as a function of current price and previous 19 values = previous MA which is fixed based on previous 20 values
The denominators which are both 20 cancel and the previous 19 values cancel. What’s left is current price on the left side and the value from 20 bars ago on the right.
Current price = value from 20 bars ago
and since the equation was set up for solving for the price of the current bar that will cause the MA to roll over
Rollover price = value from 20 bars ago
This makes plotting rollover price, both current and forecasted, fairly simple, as it’s merely the closing price plotted with an offset to the right the same distance as the moving average length.
Application:
The 20-sma and 50-sma rollover prices are plotted because they are considered to be the two most important moving averages for rollover analysis. Moving average lengths can be modified in the indicator settings. The 20-sma and 20-sma rollover price are both plotted in white and the 50-sma and 50-sma rollover price are both plotted in blue. There are two rollover prices because the 20-sma rollover price is the price that will cause the 20-sma to roll over and the 50-sma rollover price is the price that will cause the 50-sma to roll over. The one that's vertically furthest away from the current price is the one that will cause both to rollover, as should become clearer upon reading the explanation below.
The distance between the current price and the 20-sma rollover price is referred to as the “rollover strength” of the price relative to the 20-sma. A large disparity between the current price and the rollover price suggests bearishness (negative rollover strength) if the rollover price is overhead because price would need to travel all that distance in order to cause the moving average to roll up. If the rollover price and price are converging, as is often the case, a change in moving average and price direction becomes more plausible. The rollover strengths of the 20-sma and 50-sma are added together to calculate the Rollover Strength and if a negative number is the result then the background color of the plot cloud turns red. If the result is positive, it turns green. Rollover Strength is plotted below price as a separate indicator in this publication for reference only and it's not part of this indicator. It does not look much different from momentum indicators. The code is below if anybody wants to try to use it. The important thing is that the distances between the rollover prices and the price action are kept in mind as having shrinking, growing, or neutral bearish and bullish effects on current and forecasted price direction. Trades should not be entered based on cloud colorization changes alone.
If you are about to crash into a wall of the 20-sma rollover price, as is indicated on the chart by the green arrow, you might consider going long so long as the rollover strength, both current and forecasted, of the 50-sma isn’t questionably bearish. This is subject to analysis and interpretation. There was a 20-sma rollover wall as indicated with yellow arrow, but the bearish rollover strength of the 50-sma was growing and forecasted to remain strong for a while at that time so a long entry would have not been suggested by both rollover prices. If you are about to crash into both the 20-sma and 50-sma rollover prices at the same time (not shown on this chart), that’s a good time to place a trade in anticipation of both slopes changing direction. You may, in the case of this chart, see that a 20-sma rollover wall precedes a 50-sma rollover convergence with price and anticipate a cascade which turned out to be the case with this recent NQ rally.
Price exiting the cloud entirely to either the upside or downside has strong implications. When exiting to the downside, the 20-sma and 50-sma have both rolled over and price is below both of them. The same is true for upside exits. Re-entering the cloud after a rally may indicate a reversal is near, especially if the forecasted rollover prices, particularly the 50-sma, agree.
This indicator should be used in conjunction with other technical analysis tools.
Additional Notes:
The original version of this script which will not be published was much heavier, cluttered, and is not as useful. This is the light version, hence the “LTE” suffix.
LTE stands for “long-term evolution” in telecommunications, not “light.”
Bar colorization (red, yellow, and green bars) was added using the MACD Hybrid BSH script which is another script I’ve published.
If you’re not sure what a bar is, it’s the same thing as a candle or a data point on a line chart. Every vertical line showing price action on the chart above is a bar and it is a bar chart.
sma = simple moving average
Rollover Strength Script:
// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © Skipper86
//@version=5
indicator(title="Rollover Strength", shorttitle="Rollover Strength", overlay=false)
source = input.source(close)
length1 = input.int(20, "Length 1", minval=1)
length2 = input.int(50, "Length 2", minval=1)
RolloverPrice1 = source
RolloverPrice2 = source
RolloverStrength1 = source-RolloverPrice1
RolloverStrength2 = source-RolloverPrice2
RolloverStrength = RolloverStrength1 + RolloverStrength2
Color1 = color.rgb(155, 155, 155, 0)
Color2 = color.rgb(0, 0, 200, 0)
Color3 = color.rgb(0, 200, 0, 0)
plot(RolloverStrength, title="Rollover Strength", color=Color3)
hline(0, "Middle Band", color=Color1)
//End of Rollover Strength Script
Sushman Ticcy Toppy Percent Change MonitorSP 500 Trend Identifier, looks at top 5 SP500 stocks and shows performance of these 5 combined stocks for the day. Are they going up or down, TSLA< AAPL< MSFT<GOOGL<AMZN
Polynomial Regression Bands w/ Extrapolation of Price [Loxx]Polynomial Regression Bands w/ Extrapolation of Price is a moving average built on Polynomial Regression. This indicator paints both a non-repainting moving average and also a projection forecast based on the Polynomial Regression. I've included 33 source types and 38 moving average types to smooth the price input before it's run through the Polynomial Regression algorithm. This indicator only paints X many bars back so as to increase on screen calculation speed. Make sure to read the tooltips to answer any questions you have.
What is Polynomial Regression?
In statistics, polynomial regression is a form of regression analysis in which the relationship between the independent variable x and the dependent variable y is modeled as an nth degree polynomial in x. Polynomial regression fits a nonlinear relationship between the value of x and the corresponding conditional mean of y, denoted E(y |x). Although polynomial regression fits a nonlinear model to the data, as a statistical estimation problem it is linear, in the sense that the regression function E(y | x) is linear in the unknown parameters that are estimated from the data. For this reason, polynomial regression is considered to be a special case of multiple linear regression .
Related indicators
Polynomial-Regression-Fitted Oscillator
Polynomial-Regression-Fitted RSI
PA-Adaptive Polynomial Regression Fitted Moving Average
Poly Cycle
Fourier Extrapolator of Price w/ Projection Forecast
Nearest Neighbor Extrapolation of Price [Loxx]I wasn't going to post this because I don't like how this calculates by puling in the Open price, but I'm posting it anyway. This does work in it's current form but there is a. better way to do this. I'll revisit this in the future.
Anyway...
The k-Nearest Neighbor algorithm (k-NN) searches for k past patterns (neighbors) that are most similar to the current pattern and computes the future prices based on weighted voting of those neighbors. This indicator finds only one nearest neighbor. So, in essence, it is a 1-NN algorithm. It uses the Pearson correlation coefficient between the current pattern and all past patterns as the measure of distance between them. Also, this version of the nearest neighbor indicator gives larger weights to most recent prices while searching for the closest pattern in the past. It uses a weighted correlation coefficient, whose weight decays linearly from newer to older prices within a price pattern.
This indicator also includes an error window that shows whether the calculation is valid. If it's green and says "Passed", then the calculation is valid, otherwise it'll show a red background and and error message.
Inputs
Npast - number of past bars in a pattern;
Nfut -number of future bars in a pattern (must be < Npast).
lastbar - How many bars back to start forecast? Useful to show past prediction accuracy
barsbark - This prevents Pine from trying to calculate on all past bars
Related indicators
Hodrick-Prescott Extrapolation of Price
Itakura-Saito Autoregressive Extrapolation of Price
Helme-Nikias Weighted Burg AR-SE Extra. of Price
Weighted Burg AR Spectral Estimate Extrapolation of Price
Levinson-Durbin Autocorrelation Extrapolation of Price
Fourier Extrapolator of Price w/ Projection Forecast
Hodrick-Prescott Extrapolation of Price [Loxx]Hodrick-Prescott Extrapolation of Price is a Hodrick-Prescott filter used to extrapolate price.
The distinctive feature of the Hodrick-Prescott filter is that it does not delay. It is calculated by minimizing the objective function.
F = Sum((y(i) - x(i))^2,i=0..n-1) + lambda*Sum((y(i+1)+y(i-1)-2*y(i))^2,i=1..n-2)
where x() - prices, y() - filter values.
If the Hodrick-Prescott filter sees the future, then what future values does it suggest? To answer this question, we should find the digital low-frequency filter with the frequency parameter similar to the Hodrick-Prescott filter's one but with the values calculated directly using the past values of the "twin filter" itself, i.e.
y(i) = Sum(a(k)*x(i-k),k=0..nx-1) - FIR filter
or
y(i) = Sum(a(k)*x(i-k),k=0..nx-1) + Sum(b(k)*y(i-k),k=1..ny) - IIR filter
It is better to select the "twin filter" having the frequency-independent delay Тdel (constant group delay). IIR filters are not suitable. For FIR filters, the condition for a frequency-independent delay is as follows:
a(i) = +/-a(nx-1-i), i = 0..nx-1
The simplest FIR filter with constant delay is Simple Moving Average (SMA):
y(i) = Sum(x(i-k),k=0..nx-1)/nx
In case nx is an odd number, Тdel = (nx-1)/2. If we shift the values of SMA filter to the past by the amount of bars equal to Тdel, SMA values coincide with the Hodrick-Prescott filter ones. The exact math cannot be achieved due to the significant differences in the frequency parameters of the two filters.
To achieve the closest match between the filter values, I recommend their channel widths to be similar (for example, -6dB). The Hodrick-Prescott filter's channel width of -6dB is calculated as follows:
wc = 2*arcsin(0.5/lambda^0.25).
The channel width of -6dB for the SMA filter is calculated by numerical computing via the following equation:
|H(w)| = sin(nx*wc/2)/sin(wc/2)/nx = 0.5
Prediction algorithms:
The indicator features the two prediction methods:
Metod 1:
1. Set SMA length to 3 and shift it to the past by 1 bar. With such a length, the shifted SMA does not exist only for the last bar (Bar = 0), since it needs the value of the next future price Close(-1).
2. Calculate SMA filer's channel width. Equal it to the Hodrick-Prescott filter's one. Find lambda.
3. Calculate Hodrick-Prescott filter value at the last bar HP(0) and assume that SMA(0) with unknown Close(-1) gives the same value.
4. Find Close(-1) = 3*HP(0) - Close(0) - Close(1)
5. Increase the length of SMA to 5. Repeat all calculations and find Close(-2) = 5*HP(0) - Close(-1) - Close(0) - Close(1) - Close(2). Continue till the specified amount of future FutBars prices is calculated.
Method 2:
1. Set SMA length equal to 2*FutBars+1 and shift SMA to the past by FutBars
2. Calculate SMA filer's channel width. Equal it to the Hodrick-Prescott filter's one. Find lambda.
3. Calculate Hodrick-Prescott filter values at the last FutBars and assume that SMA behaves similarly when new prices appear.
4. Find Close(-1) = (2*FutBars+1)*HP(FutBars-1) - Sum(Close(i),i=0..2*FutBars-1), Close(-2) = (2*FutBars+1)*HP(FutBars-2) - Sum(Close(i),i=-1..2*FutBars-2), etc.
The indicator features the following inputs:
Method - prediction method
Last Bar - number of the last bar to check predictions on the existing prices (LastBar >= 0)
Past Bars - amount of previous bars the Hodrick-Prescott filter is calculated for (the more, the better, or at least PastBars>2*FutBars)
Future Bars - amount of predicted future values
The second method is more accurate but often has large spikes of the first predicted price. For our purposes here, this price has been filtered from being displayed in the chart. This is why method two starts its prediction 2 bars later than method 1. The described prediction method can be improved by searching for the FIR filter with the frequency parameter closer to the Hodrick-Prescott filter. For example, you may try Hanning, Blackman, Kaiser, and other filters with constant delay instead of SMA.
Related indicators
Itakura-Saito Autoregressive Extrapolation of Price
Helme-Nikias Weighted Burg AR-SE Extra. of Price
Weighted Burg AR Spectral Estimate Extrapolation of Price
Levinson-Durbin Autocorrelation Extrapolation of Price
Fourier Extrapolator of Price w/ Projection Forecast