Abstract: The invention relates to a computer implemented method of formulating a database query for searching for a data pattern in a data set stored in a database, the method comprising the following steps: receiving, from a user terminal, a series of graphical data points defining a target pattern to be searched; formulating a data structure for training a machine learning model using the series of graphical data points; training a machine learning model using the data structure; applying the trained machine learning model to the data set stored in the database to identify one or more candidate patterns, the candidate patterns comprising intervals of the data set which correspond to the target pattern within a predefined confidence level. Since the input is a series of graphical data points defining the target pattern, a specific pattern of interest may be entered much more efficiently and intuitively.