Click here to Login




A vector-based language

Updated on 2009-08-31





A vector-based programming language is different from a standard language in that it deals with arrays or vectors instead of base elements. If for example you create a new variable and associate it with the number "2", you will in fact, create an array and associate the number "2" to each element of that array.
But how is the array size defined?
The array size is defined by the asset close price. This close price is a time-series that starts at a certain date and ends at another date. The total number of bars of this time-series represents the array size. In the last example, if our stock has 500 bars, then the variable we previously created will be associated with an array of 500 elements.

Mathematical operations on vectors are easy to understand. The only thing you need to know is that these operations are executed for each element of the arrays passed as parameters.
Let's have an example. Suppose a security close price is as follows:


And suppose we want to add this security close vector to a vector initialized with the value "2".


The result will be:


All the available indicators in the QuantShare software perform calculation on vectors. Moving average, Average price, commodity channel index, relative strength index (RSI), moving average convergence/divergence (MACD) ....., all of them, get vectors as parameters and return a vector as a function return object.

One of the most important and useful QuantShare function is (ref). This function let you refer to a past or a future bar of a particular vector. Internally it just shifts the array to the right or to left depending on whether you want to refer to past or future bars. If you want to set the current vector value to the vector value three bars ago, then the (ref) function will shift the vector to the right by 3 bars.
Example:
Close price:


Ref(close, 3): (the close price three bars ago)


Ref(close, -3): (the close price three bars in the future)


In the "Formula Editor" (Right click on a chart and select "Edit formula"), you can display at any moment the content of a particular vector. You just need to right click on the formula editor control and then select "Debug Mode". You will be presented with a grid, whose rows represent the bar index and whose columns display all the vectors initialized by the formula.



A vector can be one of the following two types: Numeric or Textual. String (Text) vectors can be created as easily as numeric vectors, you just need one instruction: (a = "this is a text message";). As with numeric vectors, the string vector will store the text message in every element of the array. The text message can be set to vary from a bar to another; example: (a = "close price:".close;). NB: The point is used as an addition operator for string vectors.
String vectors are mainly used to reference and manipulate news and text data stored inside custom databases.











no comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1479 days ago

Profile Graphs
Posted 1584 days ago

QuantShare
Previous Posts

A vector-based language
Posted 5591 days ago

Data snooping bias
Posted 5604 days ago

Limit and Market orders
Posted 5615 days ago

Ranking system calculation methods
Posted 5624 days ago

RSS feeds transformation
Posted 5628 days ago

Stocks: Market Capitalization
Posted 5630 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.