ZZ_CheckingFonts 0-0020

Download script
Author: Copyright � Zhunko
ZZ_CheckingFonts 0-0020

This script is designed as a specialized visual utility for the MetaTrader 4 platform. Its primary purpose is to generate an organized, multi-row grid of symbols and corresponding numbers directly on the trading chart. Instead of placing just one icon, it automates the creation of a large sequence of labels, making them easy to reference visually.

Core Functionality

1. Dynamic Screen Management The script automatically detects the size of your current trading window. It uses this information to calculate how many symbols can fit horizontally across your screen before it runs out of space. This ensures that the layout remains as organized as possible regardless of your monitor size or window dimensions.

2. Automated Grid Layout One of the most sophisticated features of this logic is its "wrapping" system. Because there is limited horizontal space, the script calculates a specific threshold (an "Amount"). Once it reaches the end of the row, it automatically moves the next set of symbols to a new line underneath. It can generate up to 16 rows of symbols, ensuring that a large number of items are displayed in a clean, readable grid rather than overlapping or disappearing off-screen.

3. Visual Customization The script provides several user-friendly settings to tailor the display to your preference:

  • Font Selection: You can choose the specific character set (such as "Wingdings") to determine what the symbols look like.
  • Sizing & Spacing: You can adjust the size of the characters and the pixel distance between them to ensure they are legible.
  • Color Coding: It allows for two distinct colors—one for the symbols themselves and another for the identification numbers, helping you quickly differentiate between types of data.

4. Automated Cleanup and Generation To prevent clutter, the script includes a "cleanup" phase. Every time it runs, it automatically identifies and removes any existing labels created by previous versions of itself. It then proceeds to generate a fresh set of unique labels, each paired with a corresponding identification number. This creates a synchronized "key" system where every symbol on your chart is assigned a specific index for easy tracking.

12 Views
0 Downloads
0 Favorites
ZZ_CheckingFonts 0-0020
//+------------------------------------------------------------------+
//|                                       ZZ_CheckingFonts 0-0020.mq4|
//|                                       Copyright © Zhunko         |
//|21.11.2007 - 09.02.2008                zhunko@mail.ru             |
//+------------------------------------------------------------------+
#property copyright "Copyright © Zhunko"
#property link      "zhunko@mail.ru"
#property show_inputs
//----Âíåøíèå ïåðåìåííûå.---------------------------------------------
extern string NameFont  = "Wingdings"; // Íàçâàíèå øðèôòà.
extern int    SizeFonte = 20;          // Ðàçìåð ýëåìåòîâ øðèôòà íà ãðàôèêå.
extern int    DistFonte = 10;          // Äèñòàíöèÿ ìåæäó ýëåìåòàìè øðèôòà íà ãðàôèêå â ïèêñåëÿõ.
extern int    NumberFirstSymbol = 30;  // Íèæíåå îãðàíè÷åíèå íîìåðà ýëåìåíòà.
extern int    AmountSymbol = 255;      // Âåðõíåå îãðàíè÷åíèå íîìåðà ýëåìåíòà.
extern color  ColorFont = Red;         // Öâåò ýëåìåíòîâ øðèôòà íà ãðàôèêå.
extern color  ColorNumber = Yellow;    // Öâåò íîìåðîâ ýëåìåíòîâ.
//--------------------------------------------------------------------
#import "user32.dll"
 int GetClientRect (int hWnd, int lpRect[]);
#import
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
 {
  int Size = 1.3 * SizeFonte;
  int i, n;
  int XDISTANCE;
  int YDISTANCE;
  int Rect[4];
  //----
  GetClientRect (WindowHandle (Symbol(), Period()), Rect);
  Size = (Size + DistFonte);
  int Amount = (Rect[2] - Size) / Size;
  if (AmountSymbol > 455) AmountSymbol = 455;
  // Óäàëÿì âñ¸ ïî âîçìîæíîñòè.
  for (i = 0; i <= 455; i++)
   {
    ObjectDelete ("LABEL Arrow " + i);
    ObjectDelete ("LABEL Arrow ¹" + i);
   }
  // Ðèñóåì øðèôòû.
  for (i = NumberFirstSymbol; i <= AmountSymbol; i++)
   {
    n = i - NumberFirstSymbol;
    if (0 <= n && n < Amount)
     {
      XDISTANCE = Size * n + 1;
      YDISTANCE = 20;
     }
    else
     if (Amount <= n && n < 2 * Amount)
      {
       XDISTANCE = Size * n - Amount * Size + 1;
       YDISTANCE = 20 + 2 * SizeFonte;
      }
     else
      if (2 * Amount <= n && n < 3 * Amount)
       {
        XDISTANCE = Size * n - 2 * Amount * Size + 1;
        YDISTANCE = 20 + 4 * SizeFonte;
       }
      else
       if (3 * Amount <= n && n < 4 * Amount)
        {
         XDISTANCE = Size * n - 3 * Amount * Size + 1;
         YDISTANCE = 20 + 6 * SizeFonte;
        }
       else
        if (4 * Amount <= n && n < 5 * Amount)
         {
          XDISTANCE = Size * n - 4 * Amount * Size + 1;
          YDISTANCE = 20 + 8 * SizeFonte;
         }
        else
         if (5 * Amount <= n && n <  6 * Amount)
          {
           XDISTANCE = Size * n - 5 * Amount * Size + 1;
           YDISTANCE = 20 + 10 * SizeFonte;
          }
         else
          if (6 * Amount <= n && n < 7 * Amount)
           {
            XDISTANCE = Size * n - 6 * Amount * Size + 1;
            YDISTANCE = 20 + 12 * SizeFonte;
           }
          else
           if (7 * Amount <= n && n < 8 * Amount)
            {
             XDISTANCE = Size * n - 7 * Amount * Size + 1;
             YDISTANCE = 20 + 14 * SizeFonte;
            }
           else
            if (8 * Amount <= n && n < 9 * Amount)
             {
              XDISTANCE = Size * n - 8 * Amount * Size + 1;
              YDISTANCE = 20 + 16 * SizeFonte;
             }
            else
             if (9 * Amount <= n && n < 10 * Amount)
              {
               XDISTANCE = Size * n - 9 * Amount * Size + 1;
               YDISTANCE = 20 + 18 * SizeFonte;
              }
             else
              if (10 * Amount <= n && n < 11 * Amount)
               {
                XDISTANCE = Size * n - 10 * Amount * Size + 1;
                YDISTANCE = 20 + 20 * SizeFonte;
               }
              else
               if (11 * Amount <= n && n < 12 * Amount)
                {
                 XDISTANCE = Size * n - 11 * Amount * Size + 1;
                 YDISTANCE = 20 + 22 * SizeFonte;
                }
               else
                if (12 * Amount <= n && n < 13 * Amount)
                 {
                  XDISTANCE = Size * n - 12 * Amount * Size + 1;
                  YDISTANCE = 20 + 24 * SizeFonte;
                 }
                else
                 if (13 * Amount <= n && n < 14 * Amount)
                  {
                   XDISTANCE = Size * n - 13 * Amount * Size + 1;
                   YDISTANCE = 20 + 26 * SizeFonte;
                  }
                 else
                  if (14 * Amount <= n && n < 15 * Amount)
                   {
                    XDISTANCE = Size * n - 14 * Amount * Size + 1;
                    YDISTANCE = 20 + 28 * SizeFonte;
                   }
                  else
                   if (15 * Amount <= n && n < 16 * Amount)
                    {
                     XDISTANCE = Size * n - 15 * Amount * Size + 1;
                     YDISTANCE = 20 + 30 * SizeFonte;
                    }
                   else
                    if (16 * Amount <= n && n < 17 * Amount)
                     {
                      XDISTANCE = Size * n - 16 * Amount * Size + 1;
                      YDISTANCE = 20 + 32 * SizeFonte;
                     }
    // Ñîçäà¸ì îáúåêò ýëåìåíòà øðèôòà.
    ObjectCreate  ("LABEL Arrow " + i, OBJ_LABEL, 0, 0, 0, 0, 0);
    ObjectSetText ("LABEL Arrow " + i, StringSetChar ("", 0, i), SizeFonte, NameFont, ColorFont);
    ObjectSet     ("LABEL Arrow " + i, OBJPROP_ARROWCODE, i);
    ObjectSet     ("LABEL Arrow " + i, OBJPROP_CORNER, 0);
    ObjectSet     ("LABEL Arrow " + i, OBJPROP_XDISTANCE, XDISTANCE);
    ObjectSet     ("LABEL Arrow " + i, OBJPROP_YDISTANCE, YDISTANCE);
    ObjectSet     ("LABEL Arrow " + i, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
    // Ñîçäà¸ì îáúåêò íîìåð ýëåìåíòà øðèôòà.
    ObjectCreate  ("LABEL Arrow ¹" + i, OBJ_LABEL, 0, 0, 0, 0, 0);
    ObjectSetText ("LABEL Arrow ¹" + i, DoubleToStr (i, 0), 7, "Areal", ColorNumber);
    ObjectSet     ("LABEL Arrow ¹" + i, OBJPROP_CORNER, 0);
    ObjectSet     ("LABEL Arrow ¹" + i, OBJPROP_XDISTANCE, XDISTANCE);
    ObjectSet     ("LABEL Arrow ¹" + i, OBJPROP_YDISTANCE, YDISTANCE);
    ObjectSet     ("LABEL Arrow ¹" + i, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
   }
  return(0);
 }
//--------------------------------------------------------------------

Comments