Unity and Unity Pro have 103 and 102 errors
Please, provide the logs.
In my opinion it is not the sum of the currencies that should be placed equal to 1 but the weighted average of them, because currencies have a different weight in the world economic landscape.
You can do this change in the source code. Yet the idea is about assets value, and it comes solely from their exchange rates. The "weight" of currencies in the world economic could affect their volume or proprotion in the basket you trade, but their pure decoupled "prices" are determined by the cross-rates.
You can do this change in the source code. Yet the idea is about assets value, and it comes solely from their exchange rates. The "weight" of currencies in the world economic could affect their volume or proprotion in the basket you trade, but their pure decoupled "prices" are determined by the cross-rates.
You're right, but in that case the currency product must be placed equal to 1 (eur x usd x jpy...=1)
You're right, but in that case the currency product must be placed equal to 1 (eur x usd x jpy...=1)
Did you see formulae in the description? Current implementation with the sum EUR + XAU + USD = 1 still guarantees that on every bar a ratio between 2 pure currencies value is equal to their rate exchange, for example, EUR and USD have values making EURUSD quote, GBP and CHF give GBPCHF, etc. No need to have the product for this. The sum was the original idea. Of course, this is all valid only for AbsoluteValues mode on and without averaging (smoothing).
If you apply your formula, you'll probably get some other kind of relations between currencies. It can be done, but I like the idea that sum of values forms entire market more. I don't understand physical meaning of multiplication of the values.
If you like, here is a modification which calculates product (attached). Here is how both indicators look like side by side. They are almost identical.
And with smoothing:
If you see that the product reveals more knowledge from the market, please, share with us.My own:
//+---------------------------------------------------------------------+ //| Fabrizio Gargiulo 2019 - Formia (LT) ITALY | //| fajuzi@yahoo.it +393496380490 | //| MetaQuotes Software Corp. | //+---------------------------------------------------------------------+ #property copyright "MetaQuotes Software Corp. - fajuzi@yahoo.it 2019" #property link "https://www.mql5.com/en/users/fajuzi" #property description "Single currency, assuming that EUR*GBP*AUD*NZD*JPY*CAD*CHF*CNH*RUB*BRL*USD=1" //--- indicator settings --- #property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 #property indicator_type1 DRAW_LINE #property indicator_color1 clrBlue #property indicator_style1 STYLE_SOLID #property indicator_width1 2 enum currencies {EUR,GBP,AUD,NZD,JPY,CAD,CHF,CNH,RUB,BRL,USD}; input currencies single=EUR; double currency[],dollar; string simbo; int i,limit; //--- initialization function int OnInit() { IndicatorSetInteger(INDICATOR_DIGITS,5); SetIndexBuffer(0,currency,INDICATOR_DATA); IndicatorSetString(INDICATOR_SHORTNAME,EnumToString(single)); //type XUSD cross (0-3): if(single==EUR) {simbo="EURUSD"; return(INIT_SUCCEEDED);} if(single==GBP) {simbo="GBPUSD"; return(INIT_SUCCEEDED);} if(single==AUD) {simbo="AUDUSD"; return(INIT_SUCCEEDED);} if(single==NZD) {simbo="NZDUSD"; return(INIT_SUCCEEDED);} //type USDX cross (4-9): if(single==JPY) {simbo="USDJPY"; return(INIT_SUCCEEDED);} if(single==CAD) {simbo="USDCAD"; return(INIT_SUCCEEDED);} if(single==CHF) {simbo="USDCHF"; return(INIT_SUCCEEDED);} if(single==CNH) {simbo="USDCNH"; return(INIT_SUCCEEDED);} if(single==RUB) {simbo="USDRUB"; return(INIT_SUCCEEDED);} if(single==BRL) {simbo="USDBRL"; return(INIT_SUCCEEDED);} if(single==USD) return(INIT_SUCCEEDED); return(INIT_FAILED); } //+------------------------------------------------------------------+ //| Indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Custom indicator iteraction function | //+------------------------------------------------------------------+ int OnCalculate (const int rates_total, const int prev_calculated, const int begin, const double& price[] ) { ArraySetAsSeries(price,true); ArraySetAsSeries(currency,true); if(prev_calculated>rates_total){Print("Last calculated bar= ",prev_calculated,". Error.",GetLastError()); return(0);} if(prev_calculated==0) { limit=rates_total-2; } else limit=rates_total-prev_calculated; for(i=limit; i>=0 && !IsStopped(); i--) { dollar=MathPow((iClose("USDJPY",PERIOD_CURRENT,i)*iClose("USDCAD",PERIOD_CURRENT,i)*iClose("USDCHF",PERIOD_CURRENT,i)*iClose("USDCNH",PERIOD_CURRENT,i)*iClose("USDRUB",PERIOD_CURRENT,i)*iClose("USDBRL",PERIOD_CURRENT,i))/ MathMax(iClose("EURUSD",PERIOD_CURRENT,i)*iClose("GBPUSD",PERIOD_CURRENT,i)*iClose("AUDUSD",PERIOD_CURRENT,i)*iClose("NZDUSD",PERIOD_CURRENT,i),0.0001),1.0/11.0);//MathMax is to prevent zero-divide error if(single==USD) currency[i]=dollar; else { if(single<4) {currency[i]=iClose(simbo,PERIOD_CURRENT,i)*dollar;}//case XUSD else {currency[i]=dollar/MathMax(iClose(simbo,PERIOD_CURRENT,i),0.0001);}//case USDX, MathMax is to prevent zero-divide error } } return(rates_total); } //+------------------------------------------------------------------+
"
yi = xi0 / xi1 - 1,
where xi0 and xi1 are values on the last and the previous bars respectively.
"
IMHO, harmonic (average price) yield are better:
yi = (xi0 - xi1) / ( 2 / (1/xi0 + 1/xi1) )
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Unity Pro:
Multi-asset cluster indicator taking all currencies as a sum of values forming a whole market, that is unity (1.0)
Author: Stanislav Korotky