rotating_text

Download script
Author: Copyright � 2004, MetaQuotes Software Corp.
rotating_text

This script is designed to create a dynamic, animated visual element on your trading chart. Its primary purpose is to generate a rotating text label that moves across the screen while changing its appearance and message based on specific logic.

How it Works

Initial Setup When the script is activated, it identifies a starting point on your current price chart. It then places a piece of text onto the screen, initially setting the message to "Up...", coloring it green, and positioning it at a specific price level.

The Animation Loop Once the text is placed, the script enters a continuous loop that performs three simultaneous actions:

  • Movement: The text automatically travels across the chart. It shifts its horizontal position step-by-step while also moving slightly vertically as it progresses.
  • Rotation: The script continuously updates the angle of the text. This creates a spinning or "rotating" effect, where the label turns around its own axis as it moves.
  • Timing Control: The script includes a tiny pause between each movement (measured in milliseconds). This ensures that the animation appears smooth to the human eye rather than appearing instantly.

Dynamic Behavior Changes The script is programmed to change its behavior based on how far the text has traveled:

  1. Phase 1 (Upward Movement): Initially, the text moves forward while displaying "Up...".
  2. Phase 2 (Transition): After traveling a set distance, the script triggers a transformation. It switches the message to "...and Down," changes the color to an Indian Red, and reverses the direction of the movement.
  3. Reset Logic: The script also monitors its own progress; if the text returns to its starting point, it resets the color to Gold, reverts the message back to "Up...", and resumes its original forward movement.

Summary for the User

In simple terms, this is a visual "scrolling" animation tool. It creates a rotating label that travels across your chart, changes colors and messages at specific intervals, and moves back and forth, providing a decorative and kinetic element to your trading workspace.

14 Views
0 Downloads
0 Favorites
rotating_text
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                  rotate_text.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
   int    angle=0;
   int    index=0;
   double price;
   int    k=1;
//----
   price=Low[index];
   ObjectCreate("rotating_text", OBJ_TEXT, 0, Time[index], price);
   ObjectSetText("rotating_text","Up...",20);
   ObjectSet("rotating_text",OBJPROP_TIME1,Time[index]);
   ObjectSet("rotating_text",OBJPROP_PRICE1,price);
   ObjectSet("rotating_text",OBJPROP_COLOR,Green);
   while(true) 
     {
      index+=k;
      ObjectMove("rotating_text",0,Time[index],price+index*0.0001);
      ObjectSet("rotating_text",OBJPROP_ANGLE,angle);
      ObjectsRedraw();
      angle+=30;
      if(angle>3600) angle=0;
      if(index>20) 
       {
        k=-1;
        ObjectSetText("rotating_text","...and Down",20);
        ObjectSet("rotating_text",OBJPROP_COLOR,IndianRed);
       }
      if(index==0) 
       {
        k=1; 
        ObjectSetText("rotating_text","Up...",20);
        ObjectSet("rotating_text",OBJPROP_COLOR,Gold);
       }  
      Sleep(100); 
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments