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 © 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.