Click here to Login




How to plot the ratio of two stocks

Updated on 2011-07-15





To plot the ratio of two stocks or any other assets, we need to use the close price of the active symbol and divide it by the price of a referenced symbol.
There are several functions we can use to reference an external symbol. The most obvious one is: GetSeries.

Steps:
- Right click on a chart then select "Create new pane"
- Click on "Add Indicator" icon (Top-Left corner of the new pane)
- Select Operation tab
- In the first input box, type: close
- In the second input box, click on "Add", select "External Symbol", type a ticker name (next to "Select a Symbol") then click on "OK"
- Select the division (/) operator
- Click on "OK" to add the "ratio of two stocks" indicator



You can edit the previously created formula by right clicking on the pane then selecting "Edit Formula"

Here is the formula:
op1 = close / GetSeries('AA', Close);
Plot(op1, 'Operation', colorBlack, ChartLine, StyleSymbolNone);

You can change the formula title by changing the formula to:
symbol1 = "AA";
op1 = close / GetSeries(symbol1, Close);
Plot(op1, name()."/".symbol1, colorBlack, ChartLine, StyleSymbolNone);










no comments (Log in)

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 © 2012 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items