USDX or DXY Indicator

Avatar
  • updated

What Is the U.S. Dollar Index (USDX) and How to Trade It

The U.S. dollar index (USDX) is a measure of the value of the U.S. dollar relative to a basket of foreign currencies. The USDX was established by the U.S. Federal Reserve in 1973 after the dissolution of the Bretton Woods Agreement. It is now maintained by ICE Data Indices, a subsidiary of the Intercontinental Exchange (ICE).

Understanding the U.S. Dollar Index (USDX)

The index is currently calculated by factoring in the exchange rates of six foreign currencies, which include the euro (EUR), Japanese yen (JPY), Canadian dollar (CAD), British pound (GBP), Swedish krona (SEK), and Swiss franc (CHF).

The euro is, by far, the largest component of the index, making up 57.6% of the basket. The weights of the rest of the currencies in the index are JPY (13.6%), GBP (11.9%), CAD (9.1%), SEK (4.2%), and CHF (3.6%)

More info:

https://www.investopedia.com/terms/u/usdx.asp

Indicator USDX shows the USD index in form of Japanese candlesticks.

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


Calculations:

USDX = 50.14348112 × EURUSD-0.576 × USDJPY0.136 × GBPUSD-0.119 × USDCAD0.091 × USDSEK0.042 × USDCHF0.036

Image 4608

Original USDX Indicator:

USDX_Candle_original.mq5



My broker does not have the USD/SEK pair, so I removed it in the indicator code, this is wrong because the index cannot be calculated correctly, but if I do not have it in the broker, the indicator does not work. If your broker has the pair, you can use the original indicator.

Indicator without SEK:

USDX_Candle.ex5
USDX_Candle.mq5


Image 4614


Test_v2.54.set

Avatar
jay hu

Great job, Ulises! Thank you very much.

Avatar
Ulises Cune

Image 4814


Avatar
Ulises Cune

Corrected version of the previous one.

Calculated the formula without the USD/SEK pair.


Image 4815


Indicator:

USDX_Candle_without_USDSEK.ex5
USDX_Candle_without_USDSEK.mq5

Avatar
ferdinand tampubolon

how to code automatic prefix with broker?

Avatar
Ulises Cune
Quote from ferdinand tampubolon

how to code automatic prefix with broker?

Edit line 39 of the .mq5 file and add the symbols.

string symbols[]= {"EURUSD","USDJPY","GBPUSD","USDCAD","USDCHF"};

Avatar
ferdinand tampubolon
Quote from Ulises Cune

Edit line 39 of the .mq5 file and add the symbols.

string symbols[]= {"EURUSD","USDJPY","GBPUSD","USDCAD","USDCHF"};

can it use  extern int [suffix ] ??

Avatar
Ulises Cune
Quote from ferdinand tampubolon

can it use  extern int [suffix ] ??

No, edit the source code, it's easier. I do not have time now.

Avatar
ferdinand tampubolon
Quote from Ulises Cune

No, edit the source code, it's easier. I do not have time now.

ok .. it is ok bro

Avatar
Ulises Cune

I have modified the code to add suffixes automatically and if the USD/SEK pair does not exist, it recalculates the values without this pair automatically.

It also adds the pairs "EURUSD","USDJPY","GBPUSD","USDCAD","USDSEK","USDCHF" to MarketWatch automatically.

USDX_Candle_v2.ex5
USDX_Candle_v2.mq5

Avatar
jay hu
Quote from Ulises Cune

I have modified the code to add suffixes automatically and if the USD/SEK pair does not exist, it recalculates the values without this pair automatically.

It also adds the pairs "EURUSD","USDJPY","GBPUSD","USDCAD","USDSEK","USDCHF" to MarketWatch automatically.

USDX_Candle_v2.ex5
USDX_Candle_v2.mq5

Great job! Thank you for sharing this.