Before reading this post, we suggest you look at our last posts about the Statistical data analysis tool; here are the links to these two posts: Statistical data analysis of time series - Optimization in the statistical data analysis tool In this post we will show you how to create custom metrics to assess your trading rules and to perform advanced data analysis. Custom metrics are created using the JScript.Net language, which is part of the .Net framework and is a very easy programming language to learn. These metrics can be stored, categorized, and shared, which means that even if you don't know how to create them, you can always search, in the QuantShare server, for metrics that other traders have shared. In the analyzer settings, there is an item called ‘Metrics’; you just need to select it to make the metrics panel appear. You can create metrics by clicking on the 'New' or 'Add' button. The first one let you create a new metric; while the second let you load a stored metric. For each statistical data analysis you can create as many metrics as you want. Let us click on 'New' to see how we can create our own item. Clicking on this button makes a new row to appear; click on the green 'circle'. Here are some important things you need to know about Jscript.Net scripts in the QuantShare application: - Type CONTROL+SPACE to display the list of available functions and variables. - On selecting a variable or function from the list box, you will get the description of this item. Take for example the 'NbPositions' variable; this variable contains the number of positions generated by the analyzer for a specific rule and for a specific output. Note that the metric script is applied to each combination of rule-output. To create a metric, we should use the 'Functions' class which contains only one method. The syntax is very simple; take the following code as an example: Functions.AddMetric("more than 100", NbPositions > 100); This code instructs the analyzer to create a metric that display 1 when the number of generated positions exceeds 100. Of course much more complex and useful metrics could be created. You also need to know about the most important variable, which is 'Positions'. This variable is an array of objects of type 'SymbolPositionDetails' and it contains the details of all the outputs generated by the statistical data analysis tool. There is a 'SymbolPositionDetails' class for each symbol and each 'SymbolPositionDetails' contains data information only about a particular symbol. This class contains also an array of objects of type 'PositionDetails'. Each 'PositionDetails' class has three variables: Date: The date at which the pattern occured. NbBars: The position number of bars. Output: The position output.
|