Author: genino.belaev@yandex.ru
log

This tool is designed as a multi-currency visual indicator for the MetaTrader platform. Its primary purpose is to allow traders to monitor and compare the price movements of four different financial instruments simultaneously within a single, dedicated window on their charts.

Core Functionality

The script works by tracking four specific currency pairs (by default set to EURUSD, GBPUSD, AUDUSD, and NZDUSD). Instead of showing you the standard price chart for each, it calculates and displays a specialized mathematical representation of their movement over time.

How the Logic Works

  • Multi-Instrument Tracking: The tool pulls real-time data from four different assets at once. This allows you to see how various markets are behaving side-by-side without needing to open multiple separate windows.
  • Logarithmic Returns: Rather than plotting the raw price (which can be difficult to compare across different currencies with different values), the script uses a logarithmic calculation. It looks at the difference between the closing price of the current candle and the previous candle.
  • Volatility Visualization: By calculating the "log return," the tool highlights the percentage-based change in price. This makes it easier to see the relative momentum and volatility of each currency pair regardless of their actual price points.
  • Synchronized Timeline: The script ensures that all four instruments are mapped to the exact same timeframe on your main chart. As you scroll back through history, the lines will align perfectly with the time periods, allowing for a clear view of how these four currencies moved in relation to one another at any specific moment in the past.

Visual Output

The script generates four distinct lines on a separate indicator window. Each line represents one of the chosen instruments, using unique colors (Lime, DodgerBlue, White, and Yellow) to help you easily distinguish between the different markets as they fluctuate.

Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
log
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright "genino.belaev@yandex.ru"
#property link      "https://www.mql5.com/ru/users/genino"
#property version   "1.00"
#property indicator_separate_window   
#property indicator_buffers 4
#property indicator_color1 Lime       //çàäàåì öâåò 1-ãî èíñòðóìåíòà
#property indicator_color2 DodgerBlue //çàäàåì  öâåò 2-ãî èíñòðóìåíòà
#property indicator_color3 White
#property indicator_color4 Yellow
//---
extern string  Symbol_1 = "EURUSD";   //ïåðâûé èíñòðóìåíò
extern string  Symbol_2 = "GBPUSD";   //âòîðîé èíñòðóìåíò
extern string  Symbol_3 = "AUDUSD";
extern string  Symbol_4 = "NZDUSD";
double Symbol1[]; double Symbol2[];double Symbol3[];double Symbol4[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Symbol1);
   SetIndexLabel(0,Symbol_1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Symbol2);
   SetIndexLabel(1,Symbol_2);
//---
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Symbol3);
   SetIndexLabel(2,Symbol_3);
//---
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Symbol4);
   SetIndexLabel(3,Symbol_4);
//---
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars-=10;
//---
   int limit=Bars-IndicatorCounted();
   int k;
   for(k=0; k<limit-1; k++)
     {
      //--- çàäàåì îòðèñîâêó ëèíèè ïåðâîãî èíñòðóìåíòà
      Symbol1[k]=MathLog(iClose(Symbol_1,0,iBarShift(Symbol_1,0,Time[k],false)))-MathLog(iClose(Symbol_1,0,iBarShift(Symbol_1,0,Time[k+1],false)));
      //--- çàäàåì îòðèñîâêó ëèíèè ïåðâîãî èíñòðóìåíòà
      Symbol2[k]=MathLog(iClose(Symbol_2,0,iBarShift(Symbol_2,0,Time[k],false)))-MathLog(iClose(Symbol_2,0,iBarShift(Symbol_2,0,Time[k+1],false)));
      //--- çàäàåì îòðèñîâêó ëèíèè ïåðâîãî èíñòðóìåíòà
      Symbol3[k]=MathLog(iClose(Symbol_3,0,iBarShift(Symbol_3,0,Time[k],false)))-MathLog(iClose(Symbol_3,0,iBarShift(Symbol_3,0,Time[k+1],false)));
      //--- çàäàåì îòðèñîâêó ëèíèè ïåðâîãî èíñòðóìåíòà
      Symbol4[k]=MathLog(iClose(Symbol_4,0,iBarShift(Symbol_4,0,Time[k],false)))-MathLog(iClose(Symbol_4,0,iBarShift(Symbol_4,0,Time[k+1],false)));
     }
//---
   return(0);
  }
//+------------------------------------------------------------------+

Comments