I would like to create an offline chart of several different main currency indices. I don't like the way all the current currency strength meter work with moving averages,are weighted or are based around the 100 value.
Therefor I calculate the real values of any major currencies like this:
The advantage now is, that every currency pair can be calculated by just dividing the 2 corresponding values but now the EUR is capped at 1 so I calculated the relative value.
Creating an indicator which shows these values isn't enough since the changes are not big enough to be visible. However if we create an offline chart we can see the movement and the trends of the underlying currency and use this to determine the trend of our pairs.
This is the first time I am using the FileOpenHistory Function. I tried to alter the period converter to create a 1 minute offline chart based on these calculations but I got a History Base error.
Since we don't have tick values of all the currencies we don't get 100% accurate historic candles (low and high value) but since I am trading on higher timeframes it doesn't really matter for me. Once I created a 1 minute offlinechart I will just use the period converter convert it to an hourly chart and everything will be fine.
For the 1 minute timeframe we have to accept that we just know the open and close of the bars.
Cann someone please take a look and tell me why this script is not working? I tried to be careful when changing the period converter.
Therefor I calculate the real values of any major currencies like this:
Inserted Code
/* 1 random Currency will be defined with the value 1. * predefine variables */ EUR = 1; USD = 1/iClose("EURUSD",Period(),i); // USD/EUR * 1 EUR = USD CHF = 1/iClose("USDCHF",Period(),i) * USD; // CHF/USD * 1 USD = CHF GBP = 1/iClose("EURGBP",Period(),i);
Inserted Code
// EUR rel = EUR / EUR + USD + CHF + GBP <=> 1 / (USD + CHF + GBP) // USD rel = USD / EUR + USD + CHF + GBP <=> 1 / (EUR + CHF + GBP) basket= EUR + USD + CHF + GBP; EURRel[i] = EUR/basket; USDRel[i] = USD/basket; CHFRel[i] = CHF/basket; GBPRel[i] = GBP/basket;
Creating an indicator which shows these values isn't enough since the changes are not big enough to be visible. However if we create an offline chart we can see the movement and the trends of the underlying currency and use this to determine the trend of our pairs.
This is the first time I am using the FileOpenHistory Function. I tried to alter the period converter to create a 1 minute offline chart based on these calculations but I got a History Base error.
Since we don't have tick values of all the currencies we don't get 100% accurate historic candles (low and high value) but since I am trading on higher timeframes it doesn't really matter for me. Once I created a 1 minute offlinechart I will just use the period converter convert it to an hourly chart and everything will be fine.
For the 1 minute timeframe we have to accept that we just know the open and close of the bars.
Inserted Code
int barsMin = MathMin(MathMin(iBars("EURUSD",Period()),iBars("USDCHF",Period())),iBars("EURGBP",Period())); start_pos=barsMin-1; double low(int shift){ return (MathMin(close(shift),open(shift)));} double high(int shift){ return (MathMax(close(shift),open(shift)));} double open(int shift){ USD = 1/iOpen("EURUSD",Period(),shift); CHF = 1/iOpen("USDCHF",Period(),shift) * USD; GBP = 1/iOpen("EURGBP",Period(),shift); basket= EUR + USD + CHF + GBP; return (EUR/basket);} double close(int shift){ USD = 1/iClose("EURUSD",Period(),shift); CHF = 1/iClose("USDCHF",Period(),shift) * USD; GBP = 1/iClose("EURGBP",Period(),shift); basket= EUR + USD + CHF + GBP; return (EUR/basket);} double volume(int shift){ USD = 1/iVolume("EURUSD",Period(),shift); CHF = 1/iVolume("USDCHF",Period(),shift) * USD; GBP = 1/iVolume("EURGBP",Period(),shift); basket= EUR + USD + CHF + GBP; return(EUR/basket); }
Cann someone please take a look and tell me why this script is not working? I tried to be careful when changing the period converter.
Attached File(s)
CreateIndexChart.mq4
8 KB
|
297 downloads