i-Cross&Main

Download script
Author: ������� & aka KimIV
i-Cross&Main

This tool is designed to provide a visual comparison between different currency pairs on a single chart. Instead of forcing a trader to constantly switch between multiple windows to track different markets, this script consolidates specific data points into a clear, easy-to-read display.

Core Functionality

The script works by tracking three distinct currency pairs: one "Cross" pair and two "Main" pairs. It calculates the movement of these pairs over a user-defined period (determined by the number of bars on the chart) and plots them as distinct lines in a separate window beneath the main price graph.

How the Logic Works

The script processes data using two primary methods:

  • Direct Tracking: For the "Cross" pair, the tool displays its closing price directly. This allows you to see the raw performance of that specific currency relationship as it evolves over time.
  • Ratio Calculation: For the two "Main" pairs, the script performs a dynamic division. It takes the closing price of the first main pair and divides it by the closing price of the second main pair. By doing this, the tool creates a "relative strength" line. This tells you how much the first currency is moving in relation to the second, effectively filtering out some of the background market "noise."

Key Benefits for the User

  • Consolidated View: You can monitor the relationship between three different currency combinations simultaneously without cluttering your main price chart.
  • Relative Strength Analysis: By using the division logic on the main pairs, the tool helps identify whether one currency is gaining momentum compared to another, rather than just looking at their independent prices.
  • Customizable Scope: Users can control how much historical data they want to view by adjusting the number of bars, making it easy to focus on recent trends or long-term historical movements.
Price Data Components
Series array that contains close prices for each bar
9 Views
0 Downloads
0 Favorites
i-Cross&Main
//+------------------------------------------------------------------+
//|                                                 i-Cross&Main.mq4 |
//|                                              Ïîðó÷èê & aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//|  07.01.2006  Èíäèêàòîð êðîññà è ïðîèçâåäåíèÿ îñíîâíûõ ïàð.       |
//+------------------------------------------------------------------+
#property copyright "Ïîðó÷èê & aka KimIV"
#property link      "http://www.kimiv.ru"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Blue
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern string NameCross   ="GBPCHF"; // Íàèìåíîâàíèå êðîññà
extern string NameMain1   ="GBPUSD"; // Íàèìåíîâàíèå îñíîâíîé ïàðû 1
extern string NameMain2   ="USDCHF"; // Íàèìåíîâàíèå îñíîâíîé ïàðû 2
extern int    NumberOfBars=1000;     // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double buf0[], buf1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  void init() 
  {
   SetIndexBuffer(0, buf0);
   SetIndexLabel (0, NameCross);
   SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexEmptyValue(0, 0);
   SetIndexBuffer(1, buf1);
   SetIndexLabel (1, NameMain1+"/"+NameMain2);
   SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexEmptyValue(1, 0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
  void deinit() 
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
  void start() 
  {
   int LoopBegin, sh;
//----   
   if (NumberOfBars==0) LoopBegin=Bars-1;
   else LoopBegin=NumberOfBars-1;
   LoopBegin=MathMin(Bars-1, LoopBegin);
     for(sh=LoopBegin; sh>=0; sh--) 
     {
      buf0[sh]=iClose(NameCross, 0, sh);
      buf1[sh]=iClose(NameMain1, 0, sh)/iClose(NameMain2, 0, sh);
     }
  }
//+------------------------------------------------------------------+

Comments