ytg_time_zone

Author: Yuriy Tokman
Price Data Components
Series array that contains close prices for each bar
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
ytg_time_zone
//+------------------------------------------------------------------+
//|                                                ytg_time_zone.mq4 |
//|                                                     Yuriy Tokman |
//|                                         http://www.mql-design.ru |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "http://www.mql-design.ru"

#property indicator_chart_window

extern string ______1______ = "______1______";
extern bool   Switch_FIBO_1 = true;
extern color  color_RAY     = Gold;
extern int    STYLE         = 4;//0-4
extern int    WIDTH         = 1;//0-6
extern string time_start    = "2010.6.22 18:37";
extern string time_finish   = "2010.6.22 19:33";
extern int    DELTA_K       = 4;
extern string ______2______ = "______2______";
extern bool   Switch_FIBO_2 = true;
extern color  color_RAY2    = Aqua;
extern int    STYLE2        = 3;//0-4
extern int    WIDTH2        = 1;//0-6
extern string time_start2   = "2010.6.22 19:37";
extern string time_finish2  = "2010.6.22 20:33";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   GetDellName();   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   if(Switch_FIBO_1)
   GetStartLine(time_start,time_finish,"fibo1","luch1",color_RAY,STYLE,WIDTH);GetYTG();GetAvtor();
   if(Switch_FIBO_2)
   GetStartLine(time_start2,time_finish2,"fibo2","luch2",color_RAY2,STYLE,WIDTH2);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//ôóíêöèÿ ñòðîèò òåêñòîâóþ ìåòêó
 void GetTXT(string name_label,datetime t1, double p1,color c = Red, string txt = "zero",double angle = 90)
  {
   datetime dlt = DELTA_K * 60;
   if (ObjectFind(name_label)<0)// ObjectDelete(name_label);
   ObjectCreate(name_label,OBJ_TEXT,0,t1-dlt,p1,0,0);
   ObjectSet(name_label,OBJPROP_ANGLE,angle);   
   ObjectSetText(name_label, txt, 10, "Times New Roman", c);            
  } 
//ôóíêöèÿ ñòðîèò âåðòèêàëüíóþ ëèíèþ
 void GetVLINE(string name_label,datetime t1,color c = Red,int style = 0, int widh = 0)
  {
   if (ObjectFind(name_label)<0)// ObjectDelete(name_label);
   ObjectCreate(name_label,OBJ_VLINE,0,t1,0,0,0);
   ObjectSet(name_label,OBJPROP_COLOR,c);
   ObjectSet(name_label,OBJPROP_STYLE,style);   
   ObjectSet(name_label,OBJPROP_WIDTH,widh);            
  }
//ôóíêöèÿ óäàëÿåò âñå îáúåêòû ñ çàäàííûì èìåíåì
 void GetDellName (string name_n = "ytg_")
  {
   string vName;
   for(int i=ObjectsTotal()-1; i>=0;i--)
    {
     vName = ObjectName(i);
     if (StringFind(vName,name_n) !=-1) ObjectDelete(vName);
    }  
  }
//----+ôóíêöèÿ ñòðîèò âñå ëèíèè fibo time
 void GetStartLine(string ti_s, string ti_f, string n, string l, color c , int s, int w)//,s,w
  {
   GetDellName (l);
                
   GetVLINE(n+"ytg_zoltan1",StrToTime(ti_s),c,s,w);
   GetVLINE(n+"ytg_zoltan2",StrToTime(ti_f),c,s,w);
   datetime time_s =0, time_f =0, time_c = 0;
   if(ObjectFind(n+"ytg_zoltan1")!=-1) time_s = ObjectGet(n+"ytg_zoltan1",OBJPROP_TIME1);
   if(ObjectFind(n+"ytg_zoltan2")!=-1) time_f = ObjectGet(n+"ytg_zoltan2",OBJPROP_TIME1);
   
   int bars_1 = iBarShift(Symbol(),1,time_s);   
   int bars_2 = iBarShift(Symbol(),1,time_f);Comment(bars_1,"  ",bars_2);
   double delta_bars = (bars_1-bars_2)/61.8;
   double prise_b = iClose(Symbol(),1,bars_1);
   
   GetTXT(l+"ytg_zoltan11",time_s, prise_b,c,"0");   
   GetTXT(l+"ytg_zoltan22",time_f, prise_b,c,"0.618");   
      
   int bar_shift = bars_2 - NormalizeDouble(17.2*delta_bars,0);
   if(bar_shift<0)time_c = iTime(Symbol(),1,0)+MathAbs(bar_shift)*60;
   else time_c = iTime(Symbol(),1,bar_shift);   
   GetVLINE(l+"ytg_zoltan3",time_c,c,s,w);//2
   GetTXT(l+"ytg_zoltan33",time_c, prise_b,c,"0.79");
   if(bar_shift==0)Alert("0.79");
     
   bar_shift = bar_shift - NormalizeDouble(delta_bars*21,0);
   if(bar_shift<0)time_c = iTime(Symbol(),1,0)+MathAbs(bar_shift)*60;
   else time_c = iTime(Symbol(),1,bar_shift);      
   GetVLINE(l+"ytg_zoltan4",time_c,c,s,w);//3
   GetTXT(l+"ytg_zoltan44",time_c, prise_b,c,"1.0");
   if(bar_shift==0)Alert("1.0");
      
   bar_shift = bar_shift - NormalizeDouble(delta_bars*27,0);
   if(bar_shift<0)time_c = iTime(Symbol(),1,0)+MathAbs(bar_shift)*60;
   else time_c = iTime(Symbol(),1,bar_shift);            
   GetVLINE(l+"ytg_zoltan5",time_c,c,s,w);//4
   GetTXT(l+"ytg_zoltan55",time_c, prise_b,c,"1.27");
   if(bar_shift==0)Alert("1.27");
      
   bar_shift = bar_shift - NormalizeDouble(delta_bars*34.8,0);
   if(bar_shift<0)time_c = iTime(Symbol(),1,0)+MathAbs(bar_shift)*60;
   else time_c = iTime(Symbol(),1,bar_shift);         
   GetVLINE(l+"ytg_zoltan6",time_c,c,s,w);//8
   GetTXT(l+"ytg_zoltan66",time_c, prise_b,c,"1.618");
   if(bar_shift==0)Alert("1.618");
   
   bar_shift = bar_shift - NormalizeDouble(delta_bars*38.2,0);
   if(bar_shift<0)time_c = iTime(Symbol(),1,0)+MathAbs(bar_shift)*60;
   else time_c = iTime(Symbol(),1,bar_shift);      
   GetVLINE(l+"ytg_zoltan7",time_c,c,s,w);//13
   GetTXT(l+"ytg_zoltan77",time_c, prise_b,c,"2.0");
   if(bar_shift==0)Alert("2.0");             
  }
 void Label(string name_label,          
            string text_label,          
            int corner = 2,        
            int x = 3,                  
            int y = 15,               
            int font_size = 10,       
            string font_name = "Arial",  
            color text_color = LimeGreen 
           )
  {
   if (ObjectFind(name_label)!=-1) ObjectDelete(name_label);
       ObjectCreate(name_label,OBJ_LABEL,0,0,0,0,0);         
       ObjectSet(name_label,OBJPROP_CORNER,corner);
       ObjectSet(name_label,OBJPROP_XDISTANCE,x);
       ObjectSet(name_label,OBJPROP_YDISTANCE,y);
       ObjectSetText(name_label,text_label,font_size,font_name,text_color);
  }
//----+
 void GetYTG()
  {
   static int count = 0;
   count++;if(count>2)count = 0;   
   color color_Y = Red;
   color color_T = Lime;   
   color color_G = Blue;
   if(count==1){color_Y = Crimson;color_T = LimeGreen;color_G = DodgerBlue;}
   if(count==2){color_Y = OrangeRed;color_T = ForestGreen;color_G = RoyalBlue;}
                     
   Label("ytg_Y","Y" ,3,40,20,25,"Arial Black",color_Y);
   Label("ytg_T","T" ,3,25,5,25,"Arial Black",color_T);   
   Label("ytg_G","G" ,3,13,32,25,"Arial Black",color_G);
    
  }
void GetAvtor()
 {
  static int tick = 0;
  tick++;if(tick>=42)tick=0;
 
  string char[256]; int i;
  string f_n = "Arial";
  for (i = 0; i < 256; i++) char[i] = CharToStr(i);   
  Label("label",char[70],2,5,15,10,f_n,GetColor(41,tick));
  Label("label1",char[97],2,12,15,10,f_n,GetColor(0,tick));
  Label("label2",char[99],2,19,15,10,f_n,GetColor(1,tick));  
  Label("label3",char[116],2,26,15,10,f_n,GetColor(2,tick));  
  Label("label4",char[111],2,30,15,10,f_n,GetColor(3,tick));  
  Label("label5",char[114],2,37,15,10,f_n,GetColor(4,tick));
  Label("label6",char[121],2,42,15,10,f_n,GetColor(5,tick));  
  Label("label8",char[111],2,53,15,10,f_n,GetColor(6,tick));    
  Label("label9",char[102],2,60,15,10,f_n,GetColor(7,tick));    
  Label("label11",char[116],2,70,15,10,f_n,GetColor(8,tick));
  Label("label12",char[104],2,75,15,10,f_n,GetColor(9,tick));    
  Label("label13",char[101],2,81,15,10,f_n,GetColor(10,tick));      
  Label("label15",char[97],2,94,15,10,f_n,GetColor(11,tick));  
  Label("label16",char[100],2,101,15,10,f_n,GetColor(12,tick));
  Label("label17",char[118],2,108,15,10,f_n,GetColor(13,tick)); 
  Label("label18",char[105],2,115,15,10,f_n,GetColor(14,tick));  
  Label("label19",char[115],2,118,15,10,f_n,GetColor(15,tick));   
  Label("label20",char[101],2,125,15,10,f_n,GetColor(16,tick));
  Label("label21",char[114],2,133,15,10,f_n,GetColor(17,tick));
  Label("label22",char[115],2,138,15,10,f_n,GetColor(18,tick));  
  Label("label23",char[58],2,147,15,10,f_n,GetColor(19,tick));    
  Label("label24",char[121],2,153,15,10,f_n,GetColor(20,tick));  
  Label("label25",char[117],2,160,15,10,f_n,GetColor(21,tick));  
  Label("label26",char[114],2,167,15,10,f_n,GetColor(22,tick));  
  Label("label28",char[105],2,172,15,10,f_n,GetColor(23,tick));  
  Label("label29",char[121],2,176,15,10,f_n,GetColor(24,tick));    
  Label("label311",char[116],2,184,15,10,f_n,GetColor(25,tick));
  Label("label312",char[111],2,188,15,10,f_n,GetColor(26,tick));    
  Label("label313",char[107],2,195,15,10,f_n,GetColor(27,tick));      
  Label("label315",char[109],2,203,15,10,f_n,GetColor(28,tick));  
  Label("label316",char[97],2,214,15,10,f_n,GetColor(29,tick));
  Label("label317",char[110],2,221,15,10,f_n,GetColor(30,tick)); 
  Label("label318",char[64],2,230,15,10,f_n,GetColor(31,tick));    
  Label("label319",char[103],2,244,15,10,f_n,GetColor(32,tick));
  Label("label3411",char[109],2,251,15,10,f_n,GetColor(33,tick));
  Label("label3412",char[97],2,261,15,10,f_n,GetColor(34,tick));      
  Label("label3413",char[105],2,268,15,10,f_n,GetColor(35,tick));    
  Label("label3415",char[108],2,271,15,10,f_n,GetColor(36,tick));  
  Label("label33",char[46],2,274,15,10,f_n,GetColor(37,tick));
  Label("label34",char[99],2,278,15,10,f_n,GetColor(38,tick)); 
  Label("label35",char[111],2,286,15,10,f_n,GetColor(39,tick));  
  Label("label36",char[109],2,294,15,10,f_n,GetColor(40,tick)); //42           
 }
 color GetColor(int n, int t)
  {
   color colir = LimeGreen;
   if(n==t || n+1==t || n+2==t)colir = Yellow;
   if(n+10==t || n+11==t || n+12==t)colir = Aqua;
   if(n+20==t || n+21==t || n+22==t)colir = Gold;      
   return(colir);
  }

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---