Author: Copyright � 2009, Yuriy Tokman
ytg_2

This MetaTrader script functions as a dynamic visual notification tool designed to provide real-time information on the trading chart. Instead of analyzing complex price movements or mathematical formulas, its primary purpose is to display a rotating text alert that changes appearance automatically over time.

Core Functionality

The script operates by managing an on-screen text label. It identifies a specific area on your chart and places a message there, ensuring that the information remains visible and clear.

How It Works

The logic follows a simple three-step cycle to keep the display interactive:

  • Sequential Rotation: The script maintains an internal counter. Every time the market updates or the chart refreshes, the script advances this counter. This allows the tool to cycle through a predefined sequence of information or states.
  • Dynamic Color Cycling: To ensure the visual display remains engaging and doesn't become static, the script includes a color management system. It automatically cycles through a variety of colors (such as Red, Orange, Yellow, Lime, Blue, and others) based on its current position in the rotation sequence.
  • Visual Updating: Every time the counter advances, the script refreshes the text on your screen. It deletes the previous visual element and recreates it instantly with the new color and updated parameters. This prevents "ghosting" or overlapping graphics and ensures the display is always sharp and current.

Summary for the User

Essentially, this tool serves as a customizable status display. It provides a polished way to have text appear on your trading screen that changes its color systematically as the market moves, helping you keep track of information without cluttering your workspace with static elements.

10 Views
0 Downloads
0 Favorites
ytg_2
//+------------------------------------------------------------------+
//|                                                        ytg_2.mq4 |
//|                                   Copyright © 2009, Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_chart_window

int j = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete ("Òåêñò");  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   j=j+1;if(j>9)j=0;   
//----
   SetText("Òåêñò","Öâåò øðèôòà",1,350,50,30, "Arial Black", GetColorTF(j));   
//----
   return(0);
  }
//+----------------------------------------------------------------------------+
//|  Îïèñàíèå : Âîçâðàùàåò öâåò                                                |
//+----------------------------------------------------------------------------+
//|  Ïàðàìåòðû:                                                                |
//|  n - ïðîèçâîëüíîå ÷èñëî îò 1-10                                            |
//+----------------------------------------------------------------------------+
color GetColorTF(int n = 1) {
  switch (n) {
    case 1:  return(LightSlateGray);
    case 2:  return(Khaki);
    case 3:  return(Red);
    case 4:  return(Orange);
    case 5:  return(Yellow);
    case 6:  return(Lime);
    case 7:  return(White);
    case 8:  return(DodgerBlue);
    case 9:  return(Orchid);
    case 10: return(Blue);    
    default: return(LightPink);
  }
}

//+------------------------------------------------------------------+
void SetText(string name,string text,int CORNER,int XDISTANCE,int YDISTANCE, 
             int font_size, string font_name, color text_color=CLR_NONE)
 {
  if (ObjectFind(name)!=-1) ObjectDelete(name);
  ObjectCreate(name,OBJ_LABEL,0,0,0,0,0);         
  ObjectSet(name,OBJPROP_CORNER,CORNER);
  ObjectSet(name,OBJPROP_XDISTANCE,XDISTANCE);
  ObjectSet(name,OBJPROP_YDISTANCE,YDISTANCE);
  ObjectSetText(name,text,font_size,font_name,text_color);
 }

Comments