January 26, 2016
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 in the above screenshot.
It is also possible to create such ratio chart programmatically in AFL using the following code:
ratio = Foreign("Symbol1", "C") / Foreign("Symbol2", "C");
Plot( ratio, "ratio", colorRed )
Symbol1 and symbol2 names in the above code need to be replaced with the actual symbol names from our database we want to use.