This cannot work without further assumptions. Because the existing line is drawn with some noise, e.g. due to rounding effects, there is an infinite number of curves matching a finite section of the original curve. If you have a sufficiently small piece of the curve, there is no chance to indentify, if it is a circle, parabola, sine, tangent or a straight line.
Remember that e.g. the extrapolation of a curve by a polynomial is extremely instable for higher orders.
Imagine a straight line drawn with a pencil on paper. It looks trivial to identify this as a line and to continue it. But how do you decide in which magnitude and over which length you determine the slope? Looking with a mikroscope on the final micrometer you will see a huge colored block. So you have to take a magnification, in which the width of the line is "sufficiently" smaller than its length. Even then you can take the right and the left edge of the line such that the determination of the slope has an uncertainty.
This effect does not only appear for real lines drawn on paper, but for numerical data stored with limited precision in a computer also.
Of course, if you do know in advance, that the line is a sine, you can use the existing data points to determine the parameters. But in general you do not know the equation. Assume you get the coordinates of the curve at the red circles:
x = linspace(0, 9*pi, 100);
plot(x, y, 'ro'); hold('on');
Of course you could decide, that this is a sine wave, but this equation matchs the given points very good also:
xx = linspace(0, 10*pi, 1000);
yy = sin(xx) + exp(xx - 9.8*pi);
If you have the rightmost 4 points only, assuming that this is a straight line or a sine wave would be pure guessing. The more points you have, the more possible solutions can be excluded. But the problem remains that infinity minus a huge number is still infinity. Because an infinite number of possible curves matchs a set of given points recorded with a limited precision, you cannot guess reliably, how a section of a curve has to be extrapolated.
Is there any way for automatically continue a drawed line?
It depeneds. If you decide for a specific scale and take a specific number of "points" to obtain the parameters of a specified formula (e.g. a sine or a straight line), you can determine the parameters with a deviation, such that you can draw a "most likely" continuation together with a (in general exponentially) growing uncertainty interval.
The job seems to be very easy for human. Give a 5 year old child a pencil and it will solve this for you without noticing, that the problem is hard. But from a viewpoint of a scientist, it gets clear, that the child included a huge number of intelligent assumptions based on common sense like "healthy curves do not explode or drive around like crazy". Almost all real curves does.