Click here to Login




Create indicators, composites and trading systems using QL and CSharp

Updated on 2012-01-25





The QuantShare Language (QL) is a vector-based language used to plot time series, create trading rules, market scanners and trading systems.

CSharp (C#) and JScript.Net are two other programming languages based on the .NET framework. They can be used in addition to the QuantShare language to create and implement things that are more advanced.

The QuantShare Language is vector-based, which means that when you associate a value to a variable, you are in fact associating an array of values to this variable and each element of the array represents a trading bar (date for daily time frame and date/time for intra-day time frames).


Trading Indicators

They are hundreds of build-in technical indicators in QuantShare language.

You can plot these indicators on a chart or use them in a composite or a trading system.

Example: (Right click on a chart then select "Edit Formula")

a = rsi(14);
plot(a, "RSI", colorRed, ChartLine, StyleOwnScale);


To save this formula and use it later in "View -> Formula Indicators", select "File -> Save Formula" then save the formula under the "Formulas" directory.

Trading System Example: (Select "Analysis -> Simulator -> New -> Create trading system using the formula editor)

a = rsi(14);
buy = a > 70; // Buy when the 14-bar relative strength index is higher than 70



You can also create indicators from existing ones.

Here is an example of an indicator that measures the spread between two moving averages:

a = sma(90) - sma(30);


How CSharp can help us here?

CSharp allows you to create advanced indicators and then use these indicators as you do with the build-in ones.

A custom indicator implemented in C# is compiled and saved in a location under your database folder.

If you want to use this indicator, simply reference it by its name in the QuantShare programming language.

Example:

a = MyIndicator(20);

To implement a custom indicator, select "Tools" then "Create Functions"

For more information, read the following blog posts:
The custom trading indicators tool explained
Custom Indicator: Moving average spread
Custom Indicator: Relative Strength
Custom Indicator: Accumulation Distribution Line


Composites

The composite tool creates indices and market indicators from a specific formula. The time-series data of a composite item is associated with a new ticker symbol.

To create a market indicator that shows the number of stocks that are trading above their 30-bar moving average:

- Select "Tools -> Composites -> Add"
- Click on "Next", set "Calculate the sum of the values added to the composite) then type the following formula:

composite = close > sma(30); // Close price is higher than 30-Bar simple moving average


How CSharp can help us here?

CSharp allows you to create advanced composites that cannot be created using QuantShare language only.

An example of such composites is a one that is based on multiple other composites. You can calculate additional composites using the "AddComposite" function, and then use CSharp to create the final market index based on all the other composites.

To open the CSharp editor, click on "Script" in the second screen of "Create Composite" form.

More info:
Composite Indicators
4 original breadth indicators you should consider in your market timing strategy


Trading Systems

A trading system is a set of rules that define buy and sell signals without any ambiguity.

These set of rules are implemented using QuantShare language.

Example of a trading system:

a = rsi(14);
buy = a > 70;
sell = a < 30; // Sell when the 14-bar relative strength index is lower than 30



How CSharp can help us here?

Besides the buy, sell, short and cover rules of a trading system, you use CSharp to catch different money management events and build advanced trading strategies.

To add a money management script:

- Select a trading system then click on "Update"
- Select "Money management" tab on the top
- Click on "Add a new money management script" then "Update Script" to open the "Advanced Money Management" control

More info:
True portfolio simulation applied to trading systems
Create a trading strategy using the money management tool - Part 1 , Part 2
Basic trading system implemented using the money management tool
Money Management: Optimize a trading system


Besides indicators, composites and trading systems, CSharp can be used in many other plug-ins:
ASCII Importer: To manipulate imported data (Pre-Script and Post-Script)
Downloader: To manipulate imported data (Pre-Script and Post-Script) and to dynamically generate URLs (URL-Script)
Genetic Algorithm Optimizer: To create the fitness function
Global Script: To control QuantShare application












one comment (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1449 days ago

Profile Graphs
Posted 1554 days ago

QuantShare
Previous Posts

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.