SayaBarView
Download scriptThis tool is designed as a visual aid for traders who want to monitor the relative price difference between two different currency pairs simultaneously. Instead of manually checking multiple charts, it creates a single "bridge" view that highlights how much one currency is moving in relation to another.
How the Logic Works
The core purpose of this script is to calculate the "gap" between your currently active chart and a secondary reference currency that you define. Here is the breakdown of how it processes that information:
1. Dynamic Currency Mapping When you load the tool, it automatically identifies which currency pair you are trading. If the name of the currency pair is longer than standard limits, the script intelligently adjusts its internal naming to ensure it tracks the correct data without errors.
2. Dual-Mode Comparison The tool offers two distinct ways to calculate and display the difference between the two currencies, depending on your preference:
- Pips Mode (Standard Trading View): This is the most common way to view the data. The script calculates the distance between the current price and the reference price in terms of "Pips." It removes the "noise" of different exchange rates so you can see a clean, numerical difference of how far apart the two values are moving.
- Raw Multiplier Mode (Custom Weighting): This mode is used for more advanced calculations. It allows you to apply specific multipliers (coefficients) to both currencies. By adjusting these factors, you can weigh the importance of one currency more heavily than the other in the final calculation.
3. Visual Representation Rather than just providing a number, the script converts this mathematical difference into a visual histogram.
- The data is plotted in a separate window at the bottom of your trading screen.
- It uses a solid light-cyan bar format.
- The height of the bars represents the magnitude of the price difference; as the gap between the two currencies widens or narrows, the bars will grow or shrink accordingly.
Summary for the User
Essentially, this script acts as a "comparison gauge." If you are trading Currency A and want to know how it is performing relative to Currency B, this tool calculates that difference automatically and draws it as a moving history of bars. It helps you visualize price correlations and volatility differences at a single glance.
//+------------------------------------------------------------------+
//| SayaBarView.mq4 |
//| Copyright 2011 Masaru.Sasaki |
//| http://youtarou.blogzine.jp |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011 Masaru.Sasaki"
#property link "http://youtarou.blogzine.jp"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_minimum 0
// parameters
extern string SetCurrency = "CHFJPY";
extern bool SetPips = true;
extern double Currency_kakesu = 1;
extern double SetCurrency_kakesu = 1;
// buffers
double Sayabuf[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// Symbol check
if( StringLen(Symbol()) > 6 )
{
SetCurrency = SetCurrency+StringSubstr(Symbol(),6, StringLen(Symbol())-6);
}
SetIndexBuffer(0, Sayabuf);
SetIndexLabel(0,SetCurrency+"[Saya]");
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1,LightCyan);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit=Bars-counted_bars;
for(int i=limit-1; i>=0; i--)
{
if( SetPips )
{
Sayabuf[i] = MathAbs((Close[i]/Point)-(iClose(SetCurrency,0,i)/MarketInfo(SetCurrency,MODE_TICKSIZE)));
}else
Sayabuf[i] = MathAbs(Close[i]*Currency_kakesu-iClose(SetCurrency,0,i)*SetCurrency_kakesu);
}
return(0);
}
//+------------------------------------------------------------------+
Comments