acc_dist_graph_usd

Download script
Author: Copyright � 2009, sHrung.
acc_dist_graph_usd

This technical indicator is designed to provide a visual representation of market sentiment by analyzing the relationship between four major currency pairs against the US Dollar. Rather than looking at a single chart in isolation, the tool aggregates data from multiple sources to calculate a composite value that helps identify underlying trends.

How the Logic Works

The script functions by gathering historical price data from four specific currency pairs: GBP/USD, EUR/USD, USD/JPY, and USD/CHF. Instead of simply displaying these prices individually, the indicator performs a specific mathematical calculation to combine them into a single unified stream of information.

The core calculation follows this logic:

  • It adds the values of the USD/JPY and USD/CHF pairs together.
  • It subtracts the values of the GBP/USD and EUR/USD pairs from that total.

By combining these specific pairs in this way, the indicator creates a "composite" value. This approach is often used by traders to see how different regional currencies are moving in relation to the US Dollar simultaneously. It helps smooth out the noise of a single currency pair by providing a broader view of market movement across several major global markets at once.

Key Features

  • Customizable Lookback Period: The user can define a specific time window (the "Momentum Period") which determines how much historical data the script will analyze to generate the current line.
  • Dedicated Visual Window: The indicator operates in its own separate window below the main price chart, ensuring that the composite calculation does not clutter your primary price action view.
  • Historical Continuity: The script is designed to initialize and "fill" the data history for the specified period, ensuring that the visual line provides a consistent and readable flow of information as it moves toward the current market moment.

Summary of Purpose

Essentially, this tool acts as a multi-currency aggregator. It transforms four different data points into one single line, allowing you to monitor the combined strength and momentum of these specific currency relationships in a single, easy-to-read visual format.

Indicators Used
Accumulation/Distribution indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
acc_dist_graph_usd

#property copyright "Copyright © 2009, sHrung."
#property link      "http://www.something.com/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 AliceBlue

//---- input parameters
extern int MomPeriod=1000;
//---- buffers
//--- currencies 
double USD[];

//--- 
double ac_gbpusd[], ac_eurusd[], ac_usdjpy[];
double ac_usdchf[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   //---- additional buffers used for counting.
  IndicatorBuffers(5);


//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,USD);
   SetIndexBuffer(1,ac_gbpusd);
   SetIndexBuffer(2,ac_eurusd);
   SetIndexBuffer(3,ac_usdchf);
   SetIndexBuffer(4,ac_usdjpy);
   
   
   
//---- name for DataWindow and indicator subwindow label
   short_name="Accu/Dist Graph USD ("+MomPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"USD");
//----
   SetIndexDrawBegin(0,MomPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Four legs                                                        |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
   int a, b, c, d, e, f, g, h, ii, j;
//----
   if(Bars<=MomPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=MomPeriod;i++) USD[Bars-i]=0.0;
//----
   int limia=Bars-counted_bars;
   if(counted_bars>1) limia++;
   for(a=0; a<MomPeriod; a++)
   ac_gbpusd[a] = iAD("GBPUSD",0,a);
   
   int limib=Bars-counted_bars;
   if(counted_bars>1) limib++;
   for(b=0; b<MomPeriod; b++)
   ac_eurusd[b] = iAD("EURUSD",0,b);
   
   int limic=Bars-counted_bars;
   if(counted_bars>1) limic++;
   for(c=0; c<MomPeriod; c++)
   ac_usdjpy[c] = iAD("USDJPY",0,c);

   int limid=Bars-counted_bars;
   if(counted_bars>1) limid++;
   for(d=0; d<MomPeriod; d++)
   ac_usdchf[d] = iAD("USDCHF",0,d);

//----
 int limik=Bars-counted_bars;
   if(counted_bars>1) limik++;
   for(i=0; i<MomPeriod; i++)
//USD[i] = ac_usdjpy[i] + ac_usdchf[i] - ac_gbpusd[i] - ac_eurusd[i] ;
//----
   i=Bars-MomPeriod-1;
   if(counted_bars>=MomPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
USD[i] = ac_usdjpy[i] + ac_usdchf[i] - ac_gbpusd[i] - ac_eurusd[i] ;

    i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments