ytg_cycle_line

Author: Yuriy Tokman
Price Data Components
Series array that contains close prices for each bar
0 Views
0 Downloads
0 Favorites
ytg_cycle_line
//+------------------------------------------------------------------+
//|                                               ytg_cycle_line.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_CYCLE = Gold;
extern int   STYLE_CYCLE = 1;//0-4
extern int   WIDTH_CYCLE = 2;//0-6
extern string time_start_CYCLE = "2010.6.4 10:12";
extern string time_finish_CYCLE = "2010.6.4 10:25";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   GetDellName();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   GetCYCLE(time_start_CYCLE,time_finish_CYCLE,"ccy1","lly1",color_CYCLE,STYLE_CYCLE,WIDTH_CYCLE);GetYTG();GetAvtor();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//ôóíêöèÿ ñòðîèò âåðòèêàëüíóþ ëèíèþ
 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);
    }  
  }
//----+ôóíêöèÿ ñòðîèò âñå ëèíèè cycle
 void GetCYCLE(string ti_s, string ti_f, string n, string l, color c , int s, int w)//,s,w
  {
   GetDellName (l);
                
   GetVLINE(n+"ytg_cycle1",StrToTime(ti_s),c,s,w);
   GetVLINE(n+"ytg_cycle2",StrToTime(ti_f),c,s,w);
   datetime time_s =0, time_f =0, time_c = 0;
   if(ObjectFind(n+"ytg_cycle1")!=-1) time_s = ObjectGet(n+"ytg_cycle1",OBJPROP_TIME1);
   if(ObjectFind(n+"ytg_cycle2")!=-1) time_f = ObjectGet(n+"ytg_cycle2",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);

   int bar_shift = bars_2;
   
   while (bar_shift>0)
    {
     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_uiy3"+DoubleToStr(bar_shift,0),time_c,c,s,w);          
    }
  }
 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 ---