Use SetIndexShift()
Calculate the current and past bars taking the shift into account so the old values line up with the chart properly.
#property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //---- buffers double ma[];// Plot 5 period simple moving average 50 bars into futureint init() { SetIndexStyle(0,DRAW_LINE, 0, 2); SetIndexBuffer(0,ma); SetIndexShift(0, 50); return(0); } int deinit(){return(0);} int start(){ for(int i = 500; i >= 0; i--){ ma[i+50] = iMA(Symbol(), 0, 5, 0, 0, 0, i); } // example future calculation double slope = MathAbs((ma[50]- ma[51])/Point); int futureCount = 1; for(i = 49; i >= 0; i--){ if(ma[51] < ma[50]) ma[i] = ma[50]+(MathPow(futureCount*slope, 1.618)*Point); if(ma[51] > ma[50]) ma[i] = ma[50]-(MathPow(futureCount*slope, 1.618)*Point); futureCount++; } return(0); }
That's great. Thanks.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Is it possible to create an inidcator that plots a projection into the future for the bext x bars.
For example, take a simple indicator that plots as a line on the screen. I want to be able to project it into the future beyond the last bar zero. I need to do this as I have a predictive algorithm that calculates where the price will be in x bars beyond the current one and ideally I would like to project that onto the screen.
Any ideas anybody?