Author: Mich99
eur_V_usd2

This script is a specialized analytical tool designed to measure and visualize the relative momentum between two major currency groups: the Euro Basket and the US Dollar Basket. Instead of looking at a single currency pair, it aggregates data from multiple pairs to provide a broader market perspective on how these economic blocs are performing against one another.

Core Logic Overview

The indicator operates by calculating the "strength" of several different currencies relative to their counterparts. It then groups these strengths into two distinct baskets:

1. The Euro Basket (EUR) The script analyzes various currency pairs where the Euro is the primary currency. It looks at the performance of:

  • EUR/USD, EUR/CHF, EUR/GBP, EUR/JPY
  • EUR/AUD, EUR/CAD, EUR/NZD, and EUR/NOK

2. The US Dollar Basket (USD) Similarly, the script analyzes pairs where the US Dollar is the primary driver of movement. It calculates the performance for:

  • USD/JPY, USD/CHF, GBP/USD, and USD/RUB
  • AUD/USD, USD/CAD, NZD/USD, and USD/AUD (inverted)

How the Calculation Works

To determine the "strength" of these currencies, the script uses a mathematical technique that identifies the distance between two different moving averages. By comparing a short-term average to a long-term average, the script can determine if a currency is trending upward or downward at a specific moment in time.

Once the individual strengths of these pairs are calculated:

  • Basket Strength: The script combines all the Euro-related values into one total score and all the US Dollar-related values into a second total score.
  • Relative Comparison: It then compares these two totals against each other.

Visual Output

The tool produces three distinct lines on your chart to help you visualize market dynamics:

  • Line 1 (Euro Basket): Represents the aggregate momentum of the Euro-based currencies.
  • Line 2 (US Dollar Basket): Represents the aggregate momentum of the US Dollar-based currencies.
  • Line 3 (EUR-USD Difference): This is the most critical line for many traders. It shows the net difference between the two baskets.

By observing these lines, you can see which economic bloc currently holds the "upper hand" in the global market. When the difference line moves significantly, it indicates a shift in sentiment—showing whether the Euro is gaining strength against the Dollar or if the Dollar is asserting dominance over its global counterparts.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
eur_V_usd2

#property copyright "Mich99"
#property link      "mich99@o2.pl"

#property indicator_separate_window

#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Lime
#property indicator_color3 Gray
//---- input parameters



//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
      SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   //------------------------------
   IndicatorShortName("EURbasket-v-USDbasket-AO%");
   SetIndexLabel(0,"eur");
   SetIndexLabel(1,"usd");
   SetIndexLabel(2,"eur-usd");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 double w1 =  100;
 double w2 =  100;
 double w3 =  100;
 double w4 =  100;
 
   int    counted_bars=IndicatorCounted();
   int    limit=Bars-counted_bars;
   
   for(int i=0; i<limit; i++) {
   
   
   
   double a1 = (iMA("EURUSD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100 +0.00001);//iAO("EURUSD",0,i)- iAO("EURUSD",0,i+2); 
   double a2 = (iMA("EURCHF",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURCHF",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURCHF",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("EURCHF",0,i)-iAO("EURCHF",0,i+2);
   double a3 = (iMA("EURGBP",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURGBP",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURGBP",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("EURGBP",0,i)-iAO("EURGBP",0,i+2);
   double a4 = (iMA("EURJPY",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURJPY",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURJPY",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("EURJPY",0,i)-iAO("EURJPY",0,i+2);
   double b1 = (iMA("EURAUD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURAUD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURAUD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("EURAUD",0,i)-iAO("EURAUD",0,i+2); 
   double b2 = (iMA("EURCAD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURCAD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURCAD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("EURCAD",0,i)-iAO("EURCAD",0,i+2); 
   double b3 = (iMA("EURNZD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURNZD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURNZD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("EURNZD",0,i)- iAO("EURNZD",0,i+2); 
   double b4 = (iMA("EURNOK",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURNOK",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURNOK",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("EURNOK",0,i)-iAO("EURNOK",0,i+2); 
   
   double ua1 = -(iMA("EURUSD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("EURUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("EURUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//(iAO("EURUSD",0,i)-iAO("EURUSD",0,i+2)); 
   double ua2 =  (iMA("USDJPY",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("USDJPY",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("USDJPY",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("USDJPY",0,i)-iAO("USDJPY",0,i+2);
   double ua3 = -(iMA("GBPUSD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("GBPUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("GBPUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//(iAO("GBPUSD",0,i)-iAO("GBPUSD",0,i+2));
   double ua4 =  (iMA("USDCHF",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("USDCHF",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("USDCHF",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("USDCHF",0,i)- iAO("USDCHF",0,i+2);
   double ub1 = -(iMA("AUDUSD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("AUDUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("AUDUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//(iAO("AUDUSD",0,i)-iAO("AUDUSD",0,i+2)); 
   double ub2 =  (iMA("USDCAD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("USDCAD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("USDCAD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("USDCAD",0,i)-iAO("USDCAD",0,i+2); 
   double ub3 = -(iMA("NZDUSD",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("NZDUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("NZDUSD",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//(iAO("NZDUSD",0,i)-iAO("NZDUSD",0,i+2)); 
   double ub4 =  (iMA("USDRUB",0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA("USDRUB",0,34,0,MODE_SMA,PRICE_MEDIAN,i) )/(iMA("USDRUB",0,34,0,MODE_SMA,PRICE_MEDIAN,i)*100+0.00001);//iAO("USDRUB",0,i)-iAO("USDRUB",0,i+2); 
  
     
   double res   =  (w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4)+(w1 * b1 + w2 * b2 + w3 * b3 + w4 * b4);
   double bres   = (w1 * ua1 + w2 * ua2 + w3 * ua3 + w4 * ua4)+(w1 * ub1 + w2 * ub2 + w3 * ub3 + w4 * ub4);
  
ExtMapBuffer1[i]=res;
ExtMapBuffer2[i]=bres; 
ExtMapBuffer3[i]=res-bres; 
//if( ExtMapBuffer1[i]>ExtMapBuffer1[i+1]) ExtMapBuffer1[i]=res+bres;
//if( ExtMapBuffer1[i]<ExtMapBuffer1[i+1]) ExtMapBuffer2[i]=res+bres; 
} 
//----
   return(0);
  }
 
//+------------------------------------------------------------------+
 

Comments