Click here to Login




QuantShare Language


QuantShare Language

1. QuantShare Language

 

1.1. Introduction

 

QuantShare language is a simple, complete and fast scripting language.
It is a vector based language and contains more than 200 build-in functions and indicators.

Example of a vector-based language: if you type 'a = 1'.
The variable 'a' will be represented as an array of N elements (N represent the number of bars for a specific symbol) where each element of the array has a value of '1'.

Other examples:
c = close; 

This is the representation of the 'c' variable.

10.5

11

11.2

11

10.8

10.5

10

10

10.3

11.2




The current symbol has 10 quotes (elements).
The first column represents the first bar or bar number '0'. 

If we type now: c = close + 2;

The representation of the 'c' variable will be:

12.5

13

13.2

13

12.8

12.5

12

12

12.3

13.2




We added "2" to each element of the array.
You can see these arrays at any time using the debugger tool. (Right click on the editor).

In the next example, we will use a very common function 'ref', this function let you refer to old or future quotes. 

c = ref (close, 1) makes the array shift by one bar to the right.

 

NA

10.5

11

11.2

11

10.8

10.5

10

10

10.3




'NA' means that the element of the array contains no data.

1.2. Basic Concepts

 

A variable can be a number or a string. 

v1 = "test"; (assign the text 'test' to the variable 'v1').
v2 = 2; (assigns the number 2 to the variable v2).

You cannot do math calculation using both numeric and text variables.

v3 = v2 + 2; (Correct)
v3 = v2 + v1; (Not Correct) 

To concatenate two string variables or a string and a numeric variables: use "." (Point)

v3 = "test ".v2." test";

There are two types of functions:

  • Void function or function that does not return a value

Example: 'Plot' function plot a time-series on a chart.

  • Functions that returns a numeric or a string array

Example: 'Rsi' (Relative strength index indicator) returns a numeric array.

 

1.3. Edit a formula


Click on 'New Chart' in the 'View' menu to open a new chart.
Right click on the chart and click on 'Edit Formula'; the formula editor will open.

 

1.4. Add functions

 

There are two ways to add a function: 

  • You can add a function by typing it in the formula editor.
  • You can add a function by clicking on the 'Add void' or 'Add function' buttons; the 'Function selector' form will appear.

 



 

1.5. Function selector

 

 

 

1.6. Using the wizard

 

Click on 'Switch to wizard', in the formula editor form.


There are five columns in the wizard:

  1. Variable name (Red)
  2. Line of code
  3. Button to add 'Void' functions
  4. Button to add 'Return' functions
  5. Button to remove a line

 

You can type '//' in the second column to specify to the compiler that this line is a commentary line.
Switch to the normal editor by clicking on 'Switch to editor' button.
 

 

1.7. Functions to plot time-series

 

Here is the list of the functions that let you plot data:

  • Plot: plot a vector; you can specify the color, the graph type...
  • Plot1: plot two vectors, example: higher and lower Bollinger bands.
  • PlotCandleStick: plot an OHLC chart
  • PlotFixed: plot a fixed chart, example: average performance per day of the week or volatility for the next ten days per Relative Strength Index values
  • PlotSymbol: plot symbols above or below other graphs.
  • SetMaxScale: set the Y-Axis maximum value.
  • SetMinScale: set the Y-Axis minimum value.
  • SetScale: set the Y-Axis maximum and minimum value.
  • UpdateColor: update a graph color, on certain X-Axis values.

 

1.8. Update formulas dynamically

 

Move the mouse over a graph then right click, a small form will appear.
Tabs shown on that form refers to functions available in your formula.

If for example your formula is:
r = rsi (14);
Plot(r, "RSI", colorRed, ChartLine, StyleOwnScale);
 

Two tabs will be available (Rsi and Plot).
Under Rsi tab there is a cell whose name is 'timePeriod'; this cell has a value of "14".

Click on that value, and update it using the numeric text box or the track bar.
See how the graph updates dynamically while you change this value.

 



Click on the green button to make the form stick.

 

1.9. AutoComplete tool

 

In the 'Formula Editor', press on CTRL+SPACE, a list of 'Void' functions appears.

Now type something like 'a = ', then press on CTRL+SPACE, another list appears; this list contains all 'Return' functions.

 

There is also an 'AutoComplete' button on the 'Formula Editor'; click on that button, then type in something in the editor, the 'AutoComplete' list now appears each time you type in a letter. 

 

1.10. Tooltip information

 

Tooltip shows you information about functions.
There are two kinds of Tooltip; one that appear right after you type in '(', example: 'Plot ('.
The other Tooltip appear when you move the mouse over a function.

 

 

1.11. Debugger

 

The debugger displays the elements of the variables initialized within the formula.
In the 'Formula Editor', right click on the editor.

 

 

1.12. Formula errors

 

When typing a formula, an icon located at the top shows you whether your formula syntax is correct or not, clicking on that icon shows you the formula errors if any.
The icon is red when there is an error otherwise it is blue.

The location of the error is underlined with a dotted line.

After compiling the formula by clicking on 'Update Graph', the errors if any will be listed on the 'Compilation status' text box.




Manual

 

Back Parent

 

Download Manual in CHM or PDF format







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.