i-Cross%26Main-maloma
Download scriptThis tool is designed to help traders visualize the relationship between different currency pairs by plotting three distinct data points on a single separate window. Instead of looking at standard price charts, it calculates and displays specific mathematical correlations between a "Cross" pair and two "Main" pairs.
Here is a breakdown of the logic used in the script:
Core Functionality
The indicator works by comparing three specific values simultaneously across a user-defined number of historical bars (up to 1,000). It takes the following inputs from you:
- Cross Pair: The primary currency cross you want to track (e.g., GBP/CHF).
- Main Pairs: Two secondary currency pairs used as your base for comparison (e.g., GBP/USD and USD/CHF).
Data Calculations
The script generates three distinct lines on your screen:
- The Cross Pair Line: This simply tracks the closing price of the cross pair you specified. It serves as your primary point of reference.
- The Product Line (Main 1 * Main 2): The script calculates the mathematical product of the closing prices of your two "Main" pairs. By multiplying these two values together, it creates a combined synthetic value to see how they move in relation to one another.
- The Midpoint Line: This is an average calculation. The script takes the result of the two previous calculations (the Cross Pair price and the Product of the Main Pairs) and finds the exact middle point between them.
Purpose for the Trader
By displaying these three lines together, the tool allows you to observe how closely a specific currency cross follows the combined movement of its component pairs. If the lines move in sync, it indicates a high correlation; if they diverge, it provides a visual cue regarding market sentiment or anomalies between those specific currencies.
//+------------------------------------------------------------------+
//| 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 3
#property indicator_color1 Aqua
#property indicator_color2 Blue
#property indicator_color3 Red
//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern string NameCross = "GBPCHF"; // Íàèìåíîâàíèå êðîññà
extern string NameMain1 = "GBPUSD"; // Íàèìåíîâàíèå îñíîâíîé ïàðû 1
extern string NameMain2 = "USDCHF"; // Íàèìåíîâàíèå îñíîâíîé ïàðû 2
extern int NumberOfBars = 1000; // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double buf0[], buf1[], buf2[];
//+------------------------------------------------------------------+
//| 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);
SetIndexBuffer(2, buf2);
SetIndexLabel (2, "mid");
SetIndexStyle (2, DRAW_LINE, STYLE_SOLID, 2);
SetIndexEmptyValue(2, 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);
buf2[sh]=(iClose(NameMain1, 0, sh)*iClose(NameMain2, 0, sh)+iClose(NameCross, 0, sh))/2;
}
}
//+------------------------------------------------------------------+
Comments