moving-moving_v1.21s

Download script
moving-moving_v1.21s

This script is designed as a custom technical indicator for the MetaTrader platform that visualizes the relative performance of various major currency pairs against each other. Instead of looking at just one currency, it provides a comprehensive overview of market dynamics by normalizing and comparing seven different pairs simultaneously.

Core Logic Overview

Data Aggregation and Synthesis The tool begins by analyzing a specific set of "candles" (historical data points) across several major currency pairs: USDCHF, USDJPY, USDCAD, EURUSD, GBPUSD, and AUDUSD. It performs a complex mathematical calculation to create a base value for the US Dollar relative to these other currencies. This serves as a unified benchmark to help determine how various currencies are performing in relation to the broader market.

Normalization and Scaling To make the data readable on a single chart, the script identifies the peak performance (the maximum value) for each currency within the chosen timeframe. It then scales all results to a base level of 100. This normalization is crucial because it allows you to see the percentage of movement or growth for each currency relative to its own historical high during that period, rather than seeing raw price differences which would make the chart difficult to interpret.

Comparative Analysis The indicator tracks seven specific lines, each representing a different currency:

  • USD, EUR, GBP, CHF, JPY, AUD, and CAD. Because they are all normalized to a starting point of 100, you can easily identify which currencies are gaining strength or losing value compared to one another at any given moment.

Smoothing and Customization To prevent the visual data from appearing too erratic or "choppy," the script includes a smoothing mechanism. This calculates a moving average for each line, blending the current value with neighboring data points to create a cleaner, more fluid visual trend. Users can also adjust the "shift" to look further back into history and modify the "smooth level" to control how much of that filtering effect is applied to the lines.

Summary for the User

In simple terms, this tool acts as a "Relative Strength" dashboard. It takes the messy movements of various global currencies and simplifies them into seven smooth lines on one window. This allows you to see at a glance which currencies are leading the market and which are lagging, providing a clear picture of the current sentiment across the FX markets.

Price Data Components
Series array that contains close prices for each bar
6 Views
0 Downloads
0 Favorites
moving-moving_v1.21s
/*
  I like to moving, moving
  v1.21s (1.0 + smoothing (+level) + shifting)
  by ALeX  
*/


#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Black
#property indicator_color5 RosyBrown
#property indicator_color6 Orange
#property indicator_color7 BlueViolet

extern int candles = 100;
extern int shift = 0;
extern int smooth_level = 1;

double bufIUSD[];
double bufIEUR[];
double bufIGBP[];
double bufICHF[];
double bufIJPY[];
double bufIAUD[];
double bufICAD[];

//string names[7] = {"USD", "EUR", "GBP", "CHF", "JPY", "AUD", "CAD"};

int init()
{
  SetIndexBuffer (0, bufIUSD);
  SetIndexBuffer (1, bufIEUR);
  SetIndexBuffer (2, bufIGBP);
  SetIndexBuffer (3, bufICHF);
  SetIndexBuffer (4, bufIJPY);
  SetIndexBuffer (5, bufIAUD);
  SetIndexBuffer (6, bufICAD);

  SetIndexLabel (0, "USD");
  SetIndexLabel (1, "EUR");
  SetIndexLabel (2, "GBP");
  SetIndexLabel (3, "CHF");
  SetIndexLabel (4, "JPY");
  SetIndexLabel (5, "AUD");
  SetIndexLabel (6, "CAD");

  SetIndexStyle (0, DRAW_LINE, EMPTY, 2);
  SetIndexStyle (1, DRAW_LINE, EMPTY, 2);
  SetIndexStyle (2, DRAW_LINE, EMPTY, 2);
  SetIndexStyle (3, DRAW_LINE, EMPTY, 2);
  SetIndexStyle (4, DRAW_LINE);
  SetIndexStyle (5, DRAW_LINE);
  SetIndexStyle (6, DRAW_LINE);

  return (0);
}


int start()
{
  int i, j;
  int to;
  double USD, maxUSD=0.0, maxEUR=0.0, maxGBP=0.0, maxCHF=0.0, maxJPY=0.0, maxAUD=0.0, maxCAD=0.0;


  to = candles+shift;
  if (to > Bars-10)
    to = Bars-10;

  for (i = shift; i < to; i++)
  {
    USD = MathPow (iClose("USDCHF",0,i)*iClose("USDJPY",0,i)*iClose("USDCAD",0,i)/iClose("EURUSD",0,i)/iClose("GBPUSD",0,i)/iClose("AUDUSD",0,i), 1.0/7.0);
    maxUSD = MathMax (maxUSD, USD);
    maxEUR = MathMax (maxEUR, USD*iClose("EURUSD",0,i));
    maxGBP = MathMax (maxGBP, USD*iClose("GBPUSD",0,i));
    maxCHF = MathMax (maxCHF, USD/iClose("USDCHF",0,i));
    maxJPY = MathMax (maxJPY, USD/iClose("USDJPY",0,i));
    maxAUD = MathMax (maxAUD, USD*iClose("AUDUSD",0,i));
    maxCAD = MathMax (maxCAD, USD/iClose("USDCAD",0,i));
  }

  for (i = shift; i < to; i++)
  {
    USD = MathPow (iClose("USDCHF",0,i)*iClose("USDJPY",0,i)*iClose("USDCAD",0,i)/iClose("EURUSD",0,i)/iClose("GBPUSD",0,i)/iClose("AUDUSD",0,i), 1.0/7.0);
    bufIUSD[i] = 100*USD/maxUSD;
    bufIEUR[i] = 100*USD*iClose("EURUSD",0,i)/maxEUR;
    bufIGBP[i] = 100*USD*iClose("GBPUSD",0,i)/maxGBP;
    bufICHF[i] = 100*USD/iClose("USDCHF",0,i)/maxCHF;
    bufIJPY[i] = 100*USD/iClose("USDJPY",0,i)/maxJPY;
    bufIAUD[i] = 100*USD*iClose("AUDUSD",0,i)/maxAUD;
    bufICAD[i] = 100*USD/iClose("USDCAD",0,i)/maxCAD;
  }

  // smoothing
  for (j = 0; j < smooth_level; j++)
  {
    for (i = shift+1; i < to-1; i++)
    {
      bufIUSD[i] = (bufIUSD[i]+bufIUSD[i+1]+bufIUSD[i-1]) / 3.0;
      bufIEUR[i] = (bufIEUR[i]+bufIEUR[i+1]+bufIEUR[i-1]) / 3.0;
      bufIGBP[i] = (bufIGBP[i]+bufIGBP[i+1]+bufIGBP[i-1]) / 3.0;
      bufICHF[i] = (bufICHF[i]+bufICHF[i+1]+bufICHF[i-1]) / 3.0;
      bufIJPY[i] = (bufIJPY[i]+bufIJPY[i+1]+bufIJPY[i-1]) / 3.0;
      bufIAUD[i] = (bufIAUD[i]+bufIAUD[i+1]+bufIAUD[i-1]) / 3.0;
      bufICAD[i] = (bufICAD[i]+bufICAD[i+1]+bufICAD[i-1]) / 3.0;
    }
  }


  return (0);
}

Comments