Click here to Login




How to create your own technical analysis indicators

Updated on 2010-06-22





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.











one comment (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1241 days ago

Profile Graphs
Posted 1346 days ago

QuantShare
Previous Posts

Correlation of market indicators
Posted 5100 days ago

Backtesting Process
Posted 5114 days ago

Trading software new features
Posted 5120 days ago

Optimization of a trading system
Posted 5135 days ago


More Posts

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.