Author: Copyright 2015, mrak297.
updown

This tool is designed to provide a quick, visual overview of market movements across multiple financial instruments simultaneously. It creates an interactive dashboard on your trading chart that ranks and displays various currency pairs or assets based on their current price activity.

Core Functionality

The script scans the available symbols in your market watch and processes them to create a prioritized list. Instead of looking at every pair individually, it organizes them into a clean, button-based interface. Each button displays the name of a specific asset along with a numerical value that represents its current "range" or volatility relative to the market spread.

Key Features

  • Dynamic Sorting: The tool allows you to toggle between two different viewing modes. You can choose to sort the list based on the difference between opening and closing prices (Open/Close) or based on the highest and lowest price points reached during a specific timeframe (High/Low).
  • Visual Trend Indicators: Each item in the list is color-coded to give you an immediate sense of market direction:
    • Green: Indicates an upward trend.
    • Red: Indicates a downward trend.
    • Blue: Indicates a neutral or sideways movement.
  • Interactive Navigation: The dashboard acts as a shortcut menu. When you click on one of the buttons representing a specific symbol, the software will automatically open that asset's independent chart for a closer look.
  • Customizable Layout: The script is designed to automatically adjust its position on your screen (e.g., top-left, bottom-right) to ensure it stays out of the way of your main price action while remaining easily accessible.

How It Works for the User

The logic behind this tool focuses on "Range Calculation." By comparing current price data against historical daily highs, lows, and opens, the script calculates a relative intensity score for each pair. It then sorts these scores so that the most active or significant movements appear at the top of your list.

This allows a trader to quickly identify which markets are showing the most movement at any given moment, providing a high-level "heat map" of the market without needing to manually scroll through dozens of different tabs or windows.

Price Data Components
Series array that contains open prices of each barSeries array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
1 Views
0 Downloads
0 Favorites
updown
//+------------------------------------------------------------------+
//|                                                       UpDown.mq4 |
//|                                         Copyright 2015, mrak297. |
//|                            https://www.mql5.com/ru/users/mrak297 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, mrak297."
#property link      "https://www.mql5.com/ru/users/mrak297"
#property version   "15.6"
#property strict
#property indicator_chart_window
#define LINES 50 //Number of pairs
#define ELEMS 3  //Number of elements
//--- input parameters
input string Info       = "MODE button for change sorting.";
input int    Method     = 1;            //Method (1 open/close, 2 high/low)
input int    Num        = 10;           //Number of buttons
input int    FontSize   = 10;           //Font Size
input color  UpColor    = clrDarkGreen; //Color for uptrend
input color  DownColor  = clrOrangeRed; //Color for downtrend
input color  TextColor  = clrBlack;     //Color for text
input ENUM_BASE_CORNER CORNER=CORNER_LEFT_UPPER; //Corner
//---
string buttonname=" ";
int X;
int Y;
int ModeSort=1;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   X = 10;
   Y = 20;
   if(CORNER==CORNER_LEFT_LOWER)
     {
      Y=FontSize*2+10;
      for(int m=Num; m>=0; m--)
        {
         buttonname=IntegerToString(m);
         ButtonCreate(buttonname,clrBlack,X,Y);
         Y=Y+(FontSize*2);
        }
     }
   else if(CORNER==CORNER_RIGHT_LOWER)
     {
      Y = FontSize*2+10;
      X = X + FontSize*10;
      for(int m=Num; m>=0; m--)
        {
         buttonname=IntegerToString(m);
         ButtonCreate(buttonname,clrBlack,X,Y);
         Y=Y+(FontSize*2);
        }
     }
   else if(CORNER==CORNER_RIGHT_UPPER)
     {
      X=X+FontSize*10;
      for(int m=0; m<=Num; m++)
        {
         buttonname=IntegerToString(m);
         ButtonCreate(buttonname,clrBlack,X,Y);
         Y=Y+(FontSize*2);
        }
     }
   else
     {
      for(int m=0; m<=Num; m++)
        {
         buttonname=IntegerToString(m);
         ButtonCreate(buttonname,clrBlack,X,Y);
         Y=Y+(FontSize*2);
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   Find();
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   for(int d=Num; d>=0; d--) ObjectDelete(0,(string)d);
   return(0);
  }
//+------------------------------------------------------------------+
//| Main function                                                    |
//+------------------------------------------------------------------+
void Find()
  {
   string name;
   double Pairs[LINES][ELEMS];
//---
   ArrayInitialize(Pairs,1000);
//---
   for(int i=0; i<LINES; i++)
     {
      name=SymbolName(i,true);
      Pairs[i][0] = (double)i;
      Pairs[i][1] = CalcRange(name, Method);
      Pairs[i][2] = Moving(name);
     }
//---
   SortArray(ModeSort,Pairs);
//---
   for(int n=0; n<Num; n++)
     {
      string lName=IntegerToString(n);
      if(ObjectFind(0,lName)==0)
        {
         string lTxt=SymbolName((int)Pairs[n][0],true)+" "+DoubleToString(Pairs[n][1],0);
         ObjectSetString(0,lName,OBJPROP_TEXT,lTxt);
         if(Pairs[n][2] == 0) ObjectSetInteger(0, lName, OBJPROP_BGCOLOR, clrBlue);
         if(Pairs[n][2] == 1) ObjectSetInteger(0, lName, OBJPROP_BGCOLOR, UpColor);
         if(Pairs[n][2] == -1) ObjectSetInteger(0, lName, OBJPROP_BGCOLOR, DownColor);
        }
     }
//---
   string modebutt=IntegerToString(Num);
   if(ObjectFind(0,modebutt)==0)
     {
      ObjectSetString(0,modebutt,OBJPROP_TEXT,"MODE");
      ObjectSetInteger(0,modebutt,OBJPROP_BGCOLOR,clrDodgerBlue);
     }
  }
//+------------------------------------------------------------------+
//| Button creation                                                  |
//+------------------------------------------------------------------+
void ButtonCreate(string name,color bgcolor,int x,int y)
  {
   if(ObjectCreate(0,name,OBJ_BUTTON,0,0,0))
     {
      ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
      ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
      ObjectSetInteger(0,name,OBJPROP_XSIZE,FontSize*10);
      ObjectSetInteger(0,name,OBJPROP_YSIZE,FontSize*2);
      ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER);
      ObjectSetInteger(0,name,OBJPROP_FONTSIZE,FontSize);
      ObjectSetInteger(0,name,OBJPROP_BGCOLOR,bgcolor);
      ObjectSetInteger(0,name,OBJPROP_COLOR,TextColor);
      ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,clrNONE);
      ObjectSetInteger(0,name,OBJPROP_BACK,false);
      ObjectSetInteger(0,name,OBJPROP_STATE,false);
      ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
      ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
      ObjectSetInteger(0,name,OBJPROP_ZORDER,0);
      ObjectSetString(0,name,OBJPROP_FONT,"Arial");
     }
   return;
  }
//+------------------------------------------------------------------+
//| Array sorting                                                    |
//+------------------------------------------------------------------+
void SortArray(int mode,double &array[][])
  {
   if(mode==1)
     {
      for(int c=0; c<=(LINES*ELEMS); c++)
        {
         for(int x=0; x<LINES-1; x++)
           {
            if(array[x][1]<array[x+1][1])
              {
               for(int y=0; y<ELEMS; y++)
                 {
                  double temp1= array[x][y];
                  array[x][y] = array[x+1][y];
                  array[x+1][y]=temp1;
                 }
              }
           }
        }
     }
   else if(mode==2)
     {
      for(int d=0; d<(LINES*ELEMS); d++)
        {
         for(int a=0; a<LINES-1; a++)
           {
            if(array[a][1]>array[a+1][1])
              {
               for(int b=0; b<ELEMS; b++)
                 {
                  double temp2= array[a][b];
                  array[a][b] = array[a+1][b];
                  array[a+1][b]=temp2;
                 }
              }
           }
        }
     }
   else Print("ERROR SortArray mode.");
   return;
  }
//+------------------------------------------------------------------+
//| Click handler                                                    |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      if(sparam!=IntegerToString(Num))
        {
         string pn=StringSubstr(ObjectGetString(0,sparam,OBJPROP_TEXT),0,6);
         ObjectSetInteger(0,sparam,OBJPROP_STATE,false);
         ChartOpen(pn,15);
        }
      else
        {
         if(ModeSort==1) ModeSort=2;
         else ModeSort=1;
         WindowRedraw();
        }
     }
  }
//+------------------------------------------------------------------+
//| Range calculation                                                |
//+------------------------------------------------------------------+
double CalcRange(const string &symbol,int modecalc)
  {
   double result=0;
   double ask = SymbolInfoDouble(symbol, SYMBOL_ASK);
   double bid = SymbolInfoDouble(symbol, SYMBOL_BID);
   double spread=(double)SymbolInfoInteger(symbol,SYMBOL_SPREAD);
   double Pp=(ask-bid)/spread;
//---
   if(modecalc==1 && Pp!=0)
     {
      double op = iOpen(symbol, 1440, 0);
      double cl = iClose(symbol, 1440, 0);
      if(op>cl) result=(op-cl)/Pp;
      else if(op<cl) result=(cl-op)/Pp;
      else result=0;
     }
   if(modecalc==2 && Pp!=0)
     {
      double hi = iHigh(symbol, 1440, 0);
      double lo = iLow(symbol, 1440, 0);
      result=(hi-lo)/Pp;
     }
//---
   return(MathRound(result));
  }
//+------------------------------------------------------------------+
//| Direction detection                                              |
//+------------------------------------------------------------------+
double Moving(const string &symbol)
  {
   double res= 0;
   double op = iOpen(symbol, 1440, 0);
   double cl = iClose(symbol, 1440, 0);
   if(op > cl) res = -1;
   if(op < cl) res = 1;
   if(op==cl) res=0;
   return(res);
  }
//+-------------------------------------------------------------------+

Comments