Volume to currency (exposure) calculation

 

Hi all.

My goal: to establish exposure limits in order to diversify my entries across pairs on a multi symbol FX EA. For this I plan on having an array of volumes, which I then "operate a calculation on" to get values into an array of USD exposure values.

Where I am: I have an array with the asset exposure as Volume

Lets say USD seems to start a drop movement. I do not want to go "all-in" long on all xxxUSD pairs and short on USDJPY, because all those are highly correlated pairs (all USD) right.

So this is where I am now:

printf("EXPOSURE AS SIZE ++++++++++++++++++++");
printf("EUR "+ExposureList[0]);
printf("GBP "+ExposureList[1]);
printf("USD "+ExposureList[2]);
printf("CAD "+ExposureList[3]);
printf("JPY "+ExposureList[4]);
printf("AUD "+ExposureList[5]);
printf("CHF "+ExposureList[6]);
printf("NZD "+ExposureList[7]);

Reports what I expect it to, in this example:

EXPOSURE AS SIZE ++++++++++++++++++++

EUR 0.58

GBP 0.01

USD -0.1

CAD -0.09

JPY -0.61

AUD 0.06

CHF 0.0

NZD 0.15

EDIT: Positive means my exposure is "net long" on that asset, negative means "net short" on that asset. Signal is of key importance. On this example EUR 0.58 exposure I may want to deny further EUR long entries, and deny further JPY short entries.

Now, this is my current stage but only a stepping stone to what I want it to do.

I want this now converted to USD. Each of those currencies has a USD value. On top of that not all have the same leverage where I trade them.

So my approach was to make 2 support arrays. one with the "asset-to-USD" exchange rate, and a leverage array.

EDIT: ExchangeRate[] is loaded at start, first OnInit run, with bid values. For example EUR rate is  ExchangeRate[0] = bid value of EURUSD

If I can make it for the chart's active pair, I can do it for all of them, so I am trying this:

This looks halfway right, but not really. Any pointers please:

EXPOSURE AS USD for EURCAD++++++++++++++++++++

expBase 5800.0

expQuote -589.4999389648438


Thank you


EDIT: I found a way. cheers.

 
Nuno, this is exactly what I am looking for. Did you end up having working code for this?
 
Flying Dutchman #:
Nuno, this is exactly what I am looking for. Did you end up having working code for this?

https://www.mql5.com/en/code/45033

Strength Index Signal
Strength Index Signal
  • www.mql5.com
provides clear arrows which clearly show the direction of the currency pair.