{"id":1251,"date":"2016-01-26T07:10:55","date_gmt":"2016-01-26T12:10:55","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=1251"},"modified":"2016-01-28T07:14:57","modified_gmt":"2016-01-28T12:14:57","slug":"how-to-show-price-ratio-between-two-symbols","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2016\/01\/26\/how-to-show-price-ratio-between-two-symbols\/","title":{"rendered":"How to show price ratio between two symbols"},"content":{"rendered":"

Charting ratios between the prices of two symbols can easily be done with AmiBroker. For this purpose we can use Spread<\/strong> built-in formula available in Charts<\/strong> window:<\/p>

\"Inserting<\/p>

Then select the style as Ratio<\/strong>:<\/p>

\"Parameter<\/p>

The primary symbol (Symbol1) is the one selected in the chart window, the other symbol (Symbol2) is defined in the Parameters window, as presented in the above screenshot.<\/p>

It is also possible to create such ratio chart programmatically in AFL using the following code:<\/p>ratio <\/span>= <\/span>Foreign<\/span>(<\/span>"Symbol1"<\/span>, <\/span>"C"<\/span>) \/ <\/span>Foreign<\/span>(<\/span>"Symbol2"<\/span>, <\/span>"C"<\/span>);
<\/span>Plot<\/span>( <\/span>ratio<\/span>, <\/span>"ratio"<\/span>, <\/span>colorRed <\/span>)<\/code>

Symbol1 and symbol2 names in the above code need to be replaced with the actual symbol names from our database we want to use.<\/p>","protected":false},"excerpt":{"rendered":"

Charting ratios between the prices of two symbols can easily be done with AmiBroker. For this purpose we can use Spread built-in formula available in Charts window:Then select the style as Ratio:The primary symbol (Symbol1) is the one selected in the chart window, the other symbol (Symbol2) is defined in the Parameters window, as presented […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[53,55,80],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1251"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=1251"}],"version-history":[{"count":1,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1251\/revisions"}],"predecessor-version":[{"id":1254,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1251\/revisions\/1254"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=1251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=1251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=1251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}