ytg_fibo_time_zone

Author: Yuriy Tokman
0 Views
0 Downloads
0 Favorites
ytg_fibo_time_zone
//+------------------------------------------------------------------+
//|                                           ytg_fibo_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 color color_RAY = Gold;
extern int   STYLE = 4;//0-4
extern int   WIDTH = 1;//0-6
extern string time_start = "2010.6.3 10:12";
extern string time_finish = "2010.6.3 10:25";
extern int DELTA_K = 4;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   GetDellName();   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   GetStartLine(time_start,time_finish,"fibo1","luch1",color_RAY,STYLE,WIDTH);GetYTG();GetAvtor();
//----
   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);
   int delta_bars = bars_1-bars_2;
   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,"1");   
   
   int bar_shift = bars_2 - delta_bars;
   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,"2");
      
   bar_shift = bar_shift - delta_bars;
   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,"3");
      
   bar_shift = bar_shift - delta_bars*2;
   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,"5");
      
   bar_shift = bar_shift - delta_bars*3;
   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,"8");
   
   bar_shift = bar_shift - delta_bars*5;
   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,"13");
    
   bar_shift = bar_shift - delta_bars*8;
   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_zoltan8",time_c,c,s,w);//21
   GetTXT(l+"ytg_zoltan88",time_c, prise_b,c,"21");
       
   bar_shift = bar_shift - delta_bars*13;
   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_zoltan9",time_c,c,s,w);//34
   GetTXT(l+"ytg_zoltan99",time_c, prise_b,c,"34"); 
   
   bar_shift = bar_shift - delta_bars*21;
   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_zoltan10",time_c,c,s,w);//55
   GetTXT(l+"ytg_zoltan331",time_c, prise_b,c,"55");
      
   bar_shift = bar_shift - delta_bars*34;
   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_zoltan011",time_c,c,s,w);//89
   GetTXT(l+"ytg_zoltan332",time_c, prise_b,c,"89");
      
   bar_shift = bar_shift - delta_bars*55;
   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_zoltan12",time_c,c,s,w);//144
   GetTXT(l+"ytg_zoltan3322",time_c, prise_b,c,"144");
   
   bar_shift = bar_shift - delta_bars*89;
   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_zoltan13",time_c,c,s,w);//233
   GetTXT(l+"ytg_zoltan333",time_c, prise_b,c,"233");
      
   bar_shift = bar_shift - delta_bars*144;
   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_zoltan14",time_c,c,s,w);//377
   GetTXT(l+"ytg_zoltan334",time_c, prise_b,c,"377");
      
   bar_shift = bar_shift - delta_bars*233;
   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_zoltan15",time_c,c,s,w);//610
   GetTXT(l+"ytg_zoltan335",time_c, prise_b,c,"610");
                
  }
 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 ---