Author: Copyright 2010 Masaru.Sasaki
SayaView

The SayaView tool is designed as a multi-currency data visualization and monitoring assistant for MetaTrader 4. Its primary purpose is to allow traders to view the price action of a specific secondary currency pair directly on their current trading chart, alongside real-time spread calculations.

Core Functionality

Multi-Currency Overlay The script enables you to "superimpose" the data of another currency pair (defined in the settings) onto your active chart. Instead of switching between different windows to monitor a secondary market, you can view the Close, Open, High, Low, Ask, and Bid prices of that specific currency simultaneously with your primary analysis.

Customizable Data Visibility The logic includes toggle switches that allow users to customize what information is displayed. You can choose to show or hide specific data points—such as only viewing the "Ask" price, the "High/Low" extremes, or the "Open" prices—keeping your chart clean and focused on the specific metrics that matter most to your trading strategy.

Dynamic Spread Analysis The script performs real-time calculations to provide a detailed breakdown of market liquidity:

  • Local Spread: It calculates the current spread (the difference between the Buy and Sell price) for the chart you are currently viewing.
  • Remote Spread: It simultaneously fetches and calculates the spread for the secondary currency pair you have selected. This allows for a side-by-side comparison of market costs between two different pairs instantly.

Time Synchronization & Information Display To ensure precision in trading, the script generates a formatted text dashboard on the chart. This display provides:

  • A clear summary of both spreads (in pips).
  • The current Ask and Bid prices for both currencies.
  • A dual-clock system showing the FX Server Time alongside your PC Local Time, helping to eliminate confusion regarding trade execution timing.

How it Works for the User

When you load this script, it identifies the currency pair you want to track. It then scans the market history and live data to plot lines representing that currency's price movement. Finally, it updates the on-screen comment box continuously, providing a "live feed" of essential market statistics so you can make informed decisions without navigating away from your main workspace.

Price Data Components
Series array that contains close prices for each barSeries array that contains close prices for each barSeries array that contains open prices of each barSeries array that contains open prices of each barSeries array that contains the highest prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
SayaView
//+------------------------------------------------------------------+
//|                                                     SayaView.mq4 |
//|                                     Copyright 2011 Masaru.Sasaki |
//|                                      http://youtarou.blogzine.jp |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010 Masaru.Sasaki"
#property link      "http://youtarou.blogzine.jp"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Cyan
#property indicator_color2 Yellow
#property indicator_color3 SlateBlue
#property indicator_color4 Coral
#property indicator_color5 Orange
#property indicator_color6 DarkViolet
#property indicator_color7 Red

// parameters
extern string SetCurrency = "CHFJPY";
extern double SetCurrency_kakesu = 1;
extern bool View_Open = false;
extern bool View_High = false;
extern bool View_Low = false;
extern bool View_Ask = true;
extern bool View_Bid = false;

// buffers
double Closebuf[];  // parameter Currency close
double Openbuf[];
double Highbuf[];
double Lowbuf[];
double Askbuf[];
double Bidbuf[];
double Sayabuf[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   // Symbol check
   if( StringLen(Symbol()) > 6 )
   {
      SetCurrency = SetCurrency+StringSubstr(Symbol(),6, StringLen(Symbol())-6);
   }  

   SetIndexBuffer(0,Closebuf);
   SetIndexBuffer(1,Openbuf);
   SetIndexBuffer(2,Highbuf);
   SetIndexBuffer(3,Lowbuf);
   SetIndexBuffer(4,Askbuf);
   SetIndexBuffer(5,Bidbuf);
   SetIndexBuffer(6,Sayabuf);
   
   SetIndexLabel(0,SetCurrency+"-Close");
   SetIndexLabel(1,SetCurrency+"-Open");
   SetIndexLabel(2,SetCurrency+"-High");
   SetIndexLabel(3,SetCurrency+"-Low");
   SetIndexLabel(4,SetCurrency+"-Ask");
   SetIndexLabel(5,SetCurrency+"-Bid");
   
   SetIndexLabel(6,SetCurrency+"-SayaSignal");
   SetIndexStyle(6,DRAW_ARROW,STYLE_SOLID,1,Red);
   SetIndexArrow(6,233);

   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
double spread = (Ask-Bid)/Point;
double Ask_set = MarketInfo(SetCurrency,MODE_ASK);
double Bid_set = MarketInfo(SetCurrency,MODE_BID);
double Point_set = MarketInfo(SetCurrency,MODE_TICKSIZE);
double spread_set = (Ask_set-Bid_set)/Point_set;
datetime l_t = TimeLocal();
string l_t_str = TimeYear(l_t)+"/"+TimeMonth(l_t)+"/"+TimeDay(l_t)+"<"+TimeHour(l_t)+":"+TimeMinute(l_t)+":"+TimeSeconds(l_t)+">";
string s_t_str = Year()+"/"+Month()+"/"+Day()+"<"+Hour()+":"+Minute()+":"+Seconds()+">";

Comment("\n------------------------------------------------------------------------------------\n",
"[",Symbol(),"] Spread: ", spread," pips [Ask:",Ask,"][Bid:",Bid,"]\n["+SetCurrency+"] Spread: ", spread_set," pips [Ask:",Ask_set,"][Bid:",Bid_set,"]\n",
"------------------------------------------------------------------------------------\n",
"FX Server Time : ", s_t_str, "\n\n", "PC Local Time : ", l_t_str);

   int    counted_bars=IndicatorCounted();
   int limit=Bars-counted_bars;
   
   for(int i=limit-1; i>=0; i--)
   {
      Sayabuf[i] = MathAbs((Close[i]/Point)-(iClose(SetCurrency,0,i)/MarketInfo(SetCurrency,MODE_TICKSIZE)));
      Print("Sayabuf : ",Sayabuf[i]); // debug
      Closebuf[i] = iClose(SetCurrency,0,i)*SetCurrency_kakesu; // View
      if( View_Open ){
         Openbuf[i] = iOpen(SetCurrency,0,i);
      }else
         Openbuf[i] = EMPTY_VALUE;
         
      if( View_High ){
         Highbuf[i] = iHigh(SetCurrency,0,i)*SetCurrency_kakesu;
      }else
         Highbuf[i] = EMPTY_VALUE;
         
      if( View_Low ){
         Lowbuf[i] = iLow(SetCurrency,0,i)*SetCurrency_kakesu;
      }else
         Lowbuf[i] = EMPTY_VALUE;
         
      if( View_Ask ){
         Askbuf[i] = MarketInfo(SetCurrency,MODE_ASK)*SetCurrency_kakesu;
      }else
         Askbuf[i] = EMPTY_VALUE;
         
      if( View_Bid ){
         Bidbuf[i] = MarketInfo(SetCurrency,MODE_BID)*SetCurrency_kakesu;
      }else
         Bidbuf[i] = EMPTY_VALUE;
   }
   
   for(i=limit-1; i>=0; i--)
   {
         Sayabuf[i] = EMPTY_VALUE;
   }
   
   return(0);
}
//+------------------------------------------------------------------+

Comments