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);
|
|