rotating_text_v1
Download scriptThis script is designed to create a dynamic, animated visual element on your trading chart. Rather than appearing as a static piece of information, the tool generates an interactive text label that moves and rotates automatically to capture your attention.
How it Works
Initial Setup The script begins by identifying a specific starting point on your chart based on the most recent price data. It then places a text label at that exact location. At the start, the text is displayed in a gold color with the message "Up...", set at a clearly visible size.
Animation Logic Once activated, the script enters a continuous loop to create motion:
- Movement: The text label shifts its position along the chart's timeline. It travels horizontally and adjusts its vertical height incrementally, creating a gliding effect across your screen.
- Rotation: As the text moves, it rotates continuously. The script updates the angle of the label every few milliseconds, making the words spin in a full circle.
- Visual Refreshing: The tool constantly redraws itself to ensure that the animation remains smooth and fluid to the eye.
State Changes and Transitions The script is programmed to change its appearance based on how far it has traveled:
- Phase One: During the initial movement, the text maintains its "Up..." message and gold coloring.
- Phase Two: Once the animation reaches a specific distance (a predefined milestone in the sequence), the behavior shifts. The text automatically changes its message to "...and Down," switches its color to Indian Red, and reverses its direction of travel.
- Reset Mechanism: If the logic is forced back to the starting point, the script resets the text to its original "Up..." message and gold color to begin the cycle again.
Timing To ensure the animation isn't too fast for a human to track comfortably, the script includes a brief pause between every movement update. This creates a steady, controlled pace of motion that allows you to observe the rotation and movement clearly while the market is active.
//+------------------------------------------------------------------+
//| 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