This script is similar to the Constant Range Bars or Renko Bras. It makes a new offline chart very useful for somebody who trades hedging or carry strategies. It makes possible to chart your basket in the Metatrader and put any indicator or even EA on it!
It has a number of input parameters:
extern double Shift = 10.0;
extern string Symbol1 = "EURUSD";
extern double Weight1 = 1;
extern bool Invert1 = false;
extern string Symbol2 = "USDCHF";
extern double Weight2 = -1.6;
extern bool Invert2 = true;
extern string FileName = "SPREAD";
The resulting chart is calculated according to the formula:
Shift + Weight1 * Symbol1 + Weight2 * Symbol2
For the default input parameters it is therefore:
10 + EURUSD – 1.6 / USDCHF
The resulting file is SPREAD which you must open offline.
Note that for Metatrader all quotes must be above 0. Therefore you must match the Shift parameter (which would be a virtual 0 line) that nothing from the equation falls below 0. Otherwise you can get HistoryBase errors (check the Journal tab in the Terminal) and the offline chart can have updating problems.
When you are combining symbols with different point value make sure that you correctly set Weight parameters. For example when symbol one is EURUSD and symbol two USDJPY then Weight1 should be 100 and Weight2 -1. This way you will get: 100*EURUSD – USDJPY. You can also set Weight1 to 1 and Weight2 to -0.01 and the result would be: EURUSD – 0.01*USDJPY. Anyway resulting number should have the same order of magnitude to be most useful.
With this setup you can get virtually any chart composed from two currencies (or even more when you attach the script to offline SPREAD charts). This way you can get any basket chart in Metatrader even when your broker does not have this symbol. This can be for example a Dollar Index chart. What is really cool is that you can put any indicator on this chart or even EA and it will work.
These kinds of charts are for sure very useful for example for hedging and carry trading strategies. One can construct his own ‘symbols’ which would have desired characteristics.
This video shows a demonstration of usage of the off-line charts.
Some frequently asked questions about application of off-line charts are answered here Off-line charts FAQ.pdf.