how can I find similar patterns in a line if I got a "template-line"?

In this example, if I got the template (red), how can I find out that there are two occurences in the green one? The lines don't match exactly and the min/max values can be different, but the type is similar. Is there a way/algorithm to achieve this?
I do have the X and Y values of all these points, if that helps.
If the width of the test function will not be scaled then a simple method involves calculating the cross-correlation. The cross-correlation $(f\star g)(t)$ of two functions $f$ and $g$ quantifies how similar the two functions are for a given offset $t$.
Cross-correlation can be calculated using a convolution. You can take your test function $f(t)$, say, and convolve $f(-t):=h(t)$ with your data set function $g(t)$, wherever the test function "occurs" you will get a peak. By applying a suitable threshold (which will heavily depend on the data) you can detect occurances of $f$. I.e. occurances are indicated by $$ (f\star g)(t) = (h * g)(t) > H$$ for a suitable $H$.
Here is a very simple example where I have assumed that $f$ and $g$ are sampled at the same intervals. This is our test function:
This is our data:
Convolving them together highlights where the two curves look similar.

Here is another example with a test function which is not an odd function. One can see that the method is relatively robust under the addition of significant noise.
As said above this will not work well if the width of the test function is also being scaled. In this case I would look at wavelet transforms, they could be just what you're looking for.