Hi,
The best and faster way to do this is use a numeric software, like matlab.
if you want to implement it in c++, i advice you to use some existent forecast library.
You have a lot of models to forecast, such as auto regressive models (AR, ARX, ARMA, ARMAX, ARIMA, ...), fuzzy models, neural networks models, support vector machines models, markov chains, and so on...
This is just a simple model:
y(k)+a1y(k-1)+a2y(k-2)+...+any(k-n) = b1u(k)+b2u(k-1)+...+bmu(k-m)
Where y is your output and u is your input. 'a' and 'b' are coefficients that you can calculate them by minimizing some cost function.
Here is a example in c++ to calculate the future value (i did not tested it, there may be errors)
double forecast(double *y, double *u, bouble *a, double b)
{
double future_value = 0.0;
future_value = b[0]*u[0]+b[1]*u[1]+...+b[m-1]*u[m-1]-a[0]*y[0]+a[1]*y[1]+...+a[n-1]*y[n-1];
for(int i = 1; i < n; i++)
{
y[i] = y[i-1];
}
y[0] = future_value ;
}
Again, I suggest to use some numerical software that brings such algorithms implemented.
Otherwise, google is the best way to start
Best regards
Filipe Marques