With more than 300 indicators, the QuantShare library contains functions that range from technical analysis indicators to candlestick patterns. If you can't find what you are looking for, you can search for indicators in our sharing server or you can create your own indicator. This can be done using the .Net programming language. 1 - First, let us open the form that is used to create custom indicators. Click on "Tools" then "Create Functions". To create a new function, click on "Add", select the function name, then click on "Save". On the right panel, under "Script" group box, you can type your indicator formula. Below the script input box, you can select whether your function returns a numeric or text vector by checking or un-checking "Return Numeric Array". 2 - The variable "result" contains the array (time series) that is returned by a function. By clicking on CTRL + SPACE, inside the script text box, you can see that this variable is always visible. Here is an example: (Using CSharp - C#) VectorDate date = cFunctions.Date; for(int i=0;i<result.Length;i++) { result[i] = date[i].Day; } In the above example, we simply looped through the "result" array and assigned the bar's day of the month to every bar. 3 - To add parameters to your function and to perform calculation based on these parameters, simply click on "Add Parameter" button. For each parameter, you can specify its name, type (Number of String/Text), default value and description. If you create a parameter and name it "myparam", then this parameter can be accessed in the script by typing "myparam". "myparam[10]" will return the parameter value of bar number ten. 4 - You can also use the QuantShare vector-based compiler to compute time series and get the result in order to perform additional calculation. To get the Relative Strength Index or RSI value for the current stock, type the following function: VectorD rsi = cFunctions.CompileFormula("a = rsi(14);").GetVectorDouble("a"); You can create a function that calculates the RSI by adding the following line: result = rsi; The best way to learn how to create indicators is by downloading custom indicators in the sharing server and then taking a look at their implementation. 5 - The "cFunctions.SetForwardAndBackwardBars" function lets the trading software know how many past and future bars your function requires. A call to this function isn't mandatory, however it is highly recommended for many reasons. As an example, for a function that calculates the average close price for the previous 10 bars (Simple Moving Average), you can make the following call: cFunctions.SetForwardAndBackwardBars(10, 0); This means that your function requires 10 past bars and zero future bars. 6 - Any function you create using this tool can be used in any QuantShare plug-in. If you create a technical analysis indicator, you can then use this indicator in backtesting or with the optimizer. To do this, simply type your function name, as you do with other indicators, followed by the appropriate parameters. The "Create Functions" form allows you also to access custom databases (Intraday and Historical data) and create time series based on this data. This will be the topic of a future post.
|