Flashing Inscription

Author: Yuriy Tokman (YTG)
0 Views
0 Downloads
0 Favorites
Flashing Inscription
ÿþ//+------------------------------------------------------------------+

//|                                         Flashing Inscription.mq4 |

//|                                               Yuriy Tokman (YTG) |

//|                       https://www.mql5.com/ru/users/satop/seller |

//+------------------------------------------------------------------+

#property copyright "Yuriy Tokman (YTG)"

#property link      "https://www.mql5.com/ru/users/satop/seller"

#property version   "1.00"

#property strict



input int               seconds=0;                   //>;8G5AB2> A5:C=4, >?@545;ONI55 ?5@8>48G=>ABL 2>7=8:=>25=8O A>1KB89.

input string            InpName="Label";             // <O <5B:8 

input int               InpX=20;                     //  0AAB>O=85 ?> >A8 X 

input int               InpY=20;                     //  0AAB>O=85 ?> >A8 Y 

input string            InpFont="Arial Black";       // (@8DB 

input int               InpFontSize=40;              //  07<5@ H@8DB0 

input color             InpColor=clrRed;             // &25B 

input double            InpAngle=0.0;                // #3>; =0:;>=0 2 3@04CA0E 

input ENUM_ANCHOR_POINT InpAnchor=ANCHOR_LEFT_UPPER; // !?>A>1 ?@82O7:8 

input bool              InpBack=false;               // 1J5:B =0 704=5< ?;0=5 

input bool              InpSelection=false;          // K45;8BL 4;O ?5@5<5I5=89 

input bool              InpHidden=true;              // !:@KB 2 A?8A:5 >1J5:B>2 

input long              InpZOrder=0;                 // @8>@8B5B =0 =060B85 <KHLN 

input string            InpText="User Text";         // "5:AB <5B:8 



int trigger =1;

datetime time_start = 0;

//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- create timer

   EventSetTimer(1);

//--- A>74048< B5:AB>2CN <5B:C =0 3@0D8:5 

   LabelCreate(0,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,InpText,InpFont,InpFontSize, 

      InpColor,InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder); 

   

   trigger =1;  

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//--- destroy timer

   EventKillTimer();

   //--- C40;8< <5B:C 

   LabelDelete(0,InpName); 

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

//---



//---

  }

//+------------------------------------------------------------------+

//| Timer function                                                   |

//+------------------------------------------------------------------+

void OnTimer()

  {

//---

   if(trigger==1 && (time_start==0 || (int)TimeCurrent()-(int)time_start>seconds))

    {

     LabelTextChange(0,InpName,InpText); 

     trigger=0;

     time_start = TimeCurrent();

     ChartRedraw();      

    }

   if(trigger==0 && (int)TimeCurrent()-(int)time_start>seconds)

    {

     LabelTextChange(0,InpName,""); 

     trigger=1;

     time_start = TimeCurrent();

     ChartRedraw();

    }

//--- 

  }

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+ 

//| !>7405B B5:AB>2CN <5B:C                                          | 

//+------------------------------------------------------------------+ 

bool LabelCreate(const long              chart_ID=0,               // ID 3@0D8:0 

                 const string            name="Label",             // 8<O <5B:8 

                 const int               sub_window=0,             // =><5@ ?>4>:=0 

                 const int               x=0,                      // :>>@48=0B0 ?> >A8 X 

                 const int               y=0,                      // :>>@48=0B0 ?> >A8 Y 

                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // C3>; 3@0D8:0 4;O ?@82O7:8 

                 const string            text="Label",             // B5:AB 

                 const string            font="Arial",             // H@8DB 

                 const int               font_size=10,             // @07<5@ H@8DB0 

                 const color             clr=clrRed,               // F25B 

                 const double            angle=0.0,                // =0:;>= B5:AB0 

                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // A?>A>1 ?@82O7:8 

                 const bool              back=false,               // =0 704=5< ?;0=5 

                 const bool              selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89 

                 const bool              hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2 

                 const long              z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN 

  { 

//--- A1@>A8< 7=0G5=85 >H81:8 

   ResetLastError(); 

//--- A>74048< B5:AB>2CN <5B:C 

   if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0)) 

     { 

      Print(__FUNCTION__, 

            ": =5 C40;>AL A>740BL B5:AB>2CN <5B:C! >4 >H81:8 = ",GetLastError()); 

      return(false); 

     } 

//--- CAB0=>28< :>>@48=0BK <5B:8 

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x); 

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y); 

//--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8 

   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner); 

//--- CAB0=>28< B5:AB 

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text); 

//--- CAB0=>28< H@8DB B5:AB0 

   ObjectSetString(chart_ID,name,OBJPROP_FONT,font); 

//--- CAB0=>28< @07<5@ H@8DB0 

   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size); 

//--- CAB0=>28< C3>; =0:;>=0 B5:AB0 

   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle); 

//--- CAB0=>28< A?>A>1 ?@82O7:8 

   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor); 

//--- CAB0=>28< F25B 

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5 

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O <5B:8 <KHLN 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2 

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5 

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 

//--- CA?5H=>5 2K?>;=5=85 

   return(true); 

  }  

//+------------------------------------------------------------------+ 

//| 7<5=O5B B5:AB >1J5:B0                                           | 

//+------------------------------------------------------------------+ 

bool LabelTextChange(const long   chart_ID=0,   // ID 3@0D8:0 

                     const string name="Label", // 8<O >1J5:B0 

                     const string text="Text")  // B5:AB 

  { 

//--- A1@>A8< 7=0G5=85 >H81:8 

   ResetLastError(); 

//--- 87<5=8< B5:AB >1J5:B0 

   if(!ObjectSetString(chart_ID,name,OBJPROP_TEXT,text)) 

     { 

      Print(__FUNCTION__, 

            ": =5 C40;>AL 87<5=8BL B5:AB! >4 >H81:8 = ",GetLastError()); 

      return(false); 

     } 

//--- CA?5H=>5 2K?>;=5=85 

   return(true); 

  }

//+------------------------------------------------------------------+ 

//| #40;O5B B5:AB>2CN <5B:C                                          | 

//+------------------------------------------------------------------+ 

bool LabelDelete(const long   chart_ID=0,   // ID 3@0D8:0 

                 const string name="Label") // 8<O <5B:8 

  { 

//--- A1@>A8< 7=0G5=85 >H81:8 

   ResetLastError(); 

//--- C40;8< <5B:C 

   if(!ObjectDelete(chart_ID,name)) 

     { 

      Print(__FUNCTION__, 

            ": =5 C40;>AL C40;8BL B5:AB>2CN <5B:C! >4 >H81:8 = ",GetLastError()); 

      return(false); 

     } 

//--- CA?5H=>5 2K?>;=5=85 

   return(true); 

  } 

Comments