Author: � Coensio
CUSIV01

This tool is designed to provide traders with a visual representation of the US Dollar's relative strength against a basket of major global currencies. By aggregating data from multiple currency pairs simultaneously, it helps identify whether the USD is gaining momentum or losing ground in the broader market.

How the Logic Works

1. Multi-Currency Tracking The indicator monitors four specific currency pairs: EUR/USD, GBP/USD, AUD/USD, and USD/JPY. Instead of looking at these prices in isolation, the script calculates how much each pair is deviating from its own moving average (specifically an Exponential Moving Average).

2. Measuring Deviation For each of the four currencies, the script measures the distance between the current market price and its historical average.

  • In some pairs, it looks at the inverse relationship to ensure the data consistently reflects the strength or weakness of the US Dollar specifically.
  • These measurements are converted into standardized units (pips) so that different currencies can be compared accurately on the same scale.

3. Calculating Aggregate Strength Once the individual deviations for all four currencies are calculated, the script adds them together to create a single "USD Strength" value. This aggregate score represents the combined movement of the dollar against these major global markets:

  • A positive sum suggests that the US Dollar is showing relative strength across the basket.
  • A negative sum suggests that the US Dollar is showing relative weakness.

4. Visual Representation The tool translates this data into two distinct visual components on your chart:

  • Lines: Each of the four currency pairs is represented by its own dedicated line, allowing you to see individual performance at a glance.
  • Histograms: The bottom of the indicator features a dual-colored histogram.
    • Lime (Positive): This appears when the total USD Strength is above zero, indicating bullish momentum for the dollar.
    • Red (Negative): This appears when the total USD Strength falls below zero, indicating bearish momentum for the dollar.

By providing both individual pair data and a summarized "strength" histogram, this indicator allows you to see not just what the market is doing, but the overall direction of the US Dollar in relation to the global economy.

Price Data Components
Series array that contains close prices for each bar
Indicators Used
Moving average indicator
Miscellaneous
It issuies visual alerts to the screenImplements a curve of type %1
6 Views
0 Downloads
0 Favorites
CUSIV01
//+------------------------------------------------------------------+
//|                   Coensio Usd Strength Indicator V01 CUSIV01.mq4 |
//|                                         © Copyright 2013 Coesnio |
//|                                                  www.coensio.com |
//+------------------------------------------------------------------+
#property copyright "© Coensio"
#property link      "www.coensio.com"

#property indicator_separate_window
#property indicator_buffers 6
//Pairs
#property indicator_color1 Purple
#property indicator_color2 RoyalBlue
#property indicator_color3 Yellow
#property indicator_color4 LightBlue
//Histograms
#property indicator_color5 Lime
#property indicator_color6 Red

extern int  EMASize           = 50;
string      EaName            = "CUSIV01";
double      ExtMapBuffer1[];
double      ExtMapBuffer2[];
double      ExtMapBuffer3[];
double      ExtMapBuffer4[];
double      ExtMapBuffer5[];
double      ExtMapBuffer6[];
int         dS1,dS2,dS3,dS4   = 0;  //Deviation in pips for each symbol 
double      UsdStrength       = 0;
static bool Started           = false;
int init()
{
   //Check EA name
   if(WindowExpertName()!=EaName)
   {
      Alert("Copyright protection enabled!");
      Print("Copyright protection enabled!");
      return(0);
   }
   IndicatorShortName(EaName);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"EURUSD");
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,"GBPUSD");
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexLabel(2,"AUDUSD");
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexLabel(3,"USDJPY");   
   //Histograms
   SetIndexStyle(4,DRAW_HISTOGRAM,2,3);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexLabel(4,"BUY USD"); 
   SetIndexStyle(5,DRAW_HISTOGRAM,2,3);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexLabel(5,"SELL USD"); 

   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   int StartBars = IndicatorCounted();
   int Position=Bars-StartBars-1;
   if(!Started)
   {
      //Display labels
      DrawLabel("Name"+WindowExpertName(),WindowExpertName()+": Coensio USD Strength Indicator",20,0,Yellow,8);
      DrawLabel("Info"+WindowExpertName(),"© Copyright 2013 www.Coensio.com",20,10,Yellow,8); 
      Started=true;   
   }   
   while(Position>=0){
      dS1=-(iClose("EURUSD",NULL,Position)-iMA("EURUSD",NULL,EMASize,0,MODE_EMA,MODE_OPEN,Position))/(10*MarketInfo("EURUSD",MODE_POINT));
      dS2=-(iClose("GBPUSD",NULL,Position)-iMA("GBPUSD",NULL,EMASize,0,MODE_EMA,MODE_OPEN,Position))/(10*MarketInfo("GBPUSD",MODE_POINT));
      dS3=-(iClose("AUDUSD",NULL,Position)-iMA("AUDUSD",NULL,EMASize,0,MODE_EMA,MODE_OPEN,Position))/(10*MarketInfo("AUDUSD",MODE_POINT));
      dS4=(iClose("USDJPY",NULL,Position)-iMA("USDJPY",NULL,EMASize,0,MODE_EMA,MODE_OPEN,Position))/(10*MarketInfo("USDJPY",MODE_POINT));
      
      ExtMapBuffer1[Position]=dS1;
      ExtMapBuffer2[Position]=dS2;
      ExtMapBuffer3[Position]=dS3;
      ExtMapBuffer4[Position]=dS4;
      
      UsdStrength=(dS1+dS2+dS3+dS4);
      if(UsdStrength>0) ExtMapBuffer5[Position]=UsdStrength/4;
      if(UsdStrength<0) ExtMapBuffer6[Position]=UsdStrength/4;
 	   Position--;
   }
   
   return(0);
}

void DrawLabel(string STRING="",string TEXT="",int X=0, int Y=0,color COLOR=Blue,int FONT_SIZE=5)
{
   ObjectCreate(STRING,OBJ_LABEL,WindowFind(WindowExpertName()),0,0);
   ObjectSetText(STRING,TEXT,FONT_SIZE,"",COLOR);
   ObjectSet(STRING,OBJPROP_CORNER, 1); 
   ObjectSet(STRING,OBJPROP_XDISTANCE,X);
   ObjectSet(STRING,OBJPROP_YDISTANCE,Y);
}

Comments