acc_dist_graph_chf
Download scriptThis custom indicator is designed to provide a specialized visual representation of the Swiss Franc (CHF) in relation to other major global currencies. Instead of simply looking at one currency pair, this tool performs a complex mathematical calculation to derive a singular value that represents a broader market sentiment.
How the Logic Works
The core logic relies on comparing the performance of four different currency pairs simultaneously against the Swiss Franc. It monitors the following interactions:
- USD/CHF (US Dollar vs. Swiss Franc)
- EUR/CHF (Euro vs. Swiss Franc)
- GBP/CHF (British Pound vs. Swiss Franc)
- CHF/JPY (Swiss Franc vs. Japanese Yen)
The Calculation Process
The indicator follows a specific three-step process to generate its visual output:
- Data Collection: The script pulls the historical price data for all four of the currency pairs listed above over a specific timeframe (defined by the "MomPeriod" setting).
- Mathematical Synthesis: Rather than averaging these prices, the script performs a unique calculation. It takes the value of the CHF/JPY pair and subtracts the values of the other three pairs (USD/CHF, EUR/CHF, and GBP/CHF) from it.
- Visual Mapping: The resulting figure is then plotted as an orange line in a separate window on your chart.
Purpose for the Trader
By subtracting the major Western currencies (USD, EUR, GBP) from the Japanese Yen interaction, the indicator aims to isolate a specific movement trend. It effectively filters out the "noise" of individual currency fluctuations to highlight a synthesized value. This allows traders to see a consolidated view of how the Swiss Franc is positioned relative to a basket of heavy-hitting global currencies, potentially revealing broader trends that might be hidden when looking at single pairs in isolation.
#property copyright "Copyright © 2009, sHrung."
#property link "http://www.something.com/"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Orange
//---- input parameters
extern int MomPeriod=1000;
//---- buffers
//--- currencies
double CHF[];
//---
double ac_usdchf[];
double ac_eurchf[], ac_chfjpy[];
double ac_gbpchf[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- additional buffers used for counting.
IndicatorBuffers(5);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,CHF);
SetIndexBuffer(1,ac_usdchf);
SetIndexBuffer(2,ac_gbpchf);
SetIndexBuffer(3,ac_chfjpy);
SetIndexBuffer(4,ac_eurchf);
//---- name for DataWindow and indicator subwindow label
short_name="Accu/Dist Graph CHF ("+MomPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,"CHF");
//----
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++) CHF[Bars-i]=0.0;
//----
int limid=Bars-counted_bars;
if(counted_bars>1) limid++;
for(d=0; d<MomPeriod; d++)
ac_usdchf[d] = iAD("USDCHF",0,d);
int limig=Bars-counted_bars;
if(counted_bars>1) limig++;
for(g=0; g<MomPeriod; g++)
ac_eurchf[g] = iAD("EURCHF",0,g);
int limii=Bars-counted_bars;
if(counted_bars>1) limii++;
for(ii=0; ii<MomPeriod; ii++)
ac_chfjpy[ii] = iAD("CHFJPY",0,ii);
int limij=Bars-counted_bars;
if(counted_bars>1) limij++;
for(j=0; j<MomPeriod; j++)
ac_gbpchf[j] = iAD("GBPCHF",0,j);
//----
//----
i=Bars-MomPeriod-1;
if(counted_bars>=MomPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
CHF[i] = ac_chfjpy[i] - ac_usdchf[i] - ac_eurchf[i] - ac_gbpchf[i];
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments