//+------------------------------------------------------------------+
//|             Copyright © 2010, Konstantin http://www.fxaktiv.com  |
//|                        panelektrik@yandex.ru skype pan--elektrik |
//|                                ISQ 561090193 Ìîá.+380 50 7115118 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Konstantin"
#property link      "http://www.fxaktiv.com  panelektrik@yandex.ru skype pan--elektrik ISQ 561090193 Ìîá.+380 50 7115118"
//----
#property indicator_chart_window
#property indicator_buffers 0
//+----
 extern  datetime START = D'2011.03.01 00:00';
 extern int T1 = 0;
 extern int T2 = 9; 
//+---- 
 int den,b1,b2,median;
//+------------------------------------------------------------------+
int start()
 { 
//---- 
 static int time; if(Time[0]==time)return(0);time=Time[0];   
//----
 for(int i=iBarShift(NULL,0,START,false);i>=0;i--)
 {
 if(TimeHour(iTime(NULL,0,i))<T1||TimeHour(iTime(NULL,0,i))>T2){b1=0;b2=0;median=0;}
//---- 
 if(b1==0&&TimeHour(iTime(NULL,0,i))==T1){b1=i;den=TimeDay(iTime(NULL,0,i));}
 if(b2==0&&TimeHour(iTime(NULL,0,i))==T2&&TimeDay(iTime(NULL,0,i))==den){b2=i;}
 if(median==0&&b1>0&&b2>0){median=NormalizeDouble((b1-b2)/2,0);}
//+----
 if(median>0&&b1>0&&b2>0){
//+---- 
 double H1 = High[iHighest(NULL,0,MODE_HIGH,median,b1-median)];
 double H2 = High[iHighest(NULL,0,MODE_HIGH,median,b2)];
//- 
 double L1 = Low[iLowest(NULL,0,MODE_LOW,median,b1-median)];
 double L2 = Low[iLowest(NULL,0,MODE_LOW,median,b2)];
//+----
 int BB1=iHighest(NULL,0,MODE_HIGH,median,b1-median);
 int BB2=iHighest(NULL,0,MODE_HIGH,median,b2); 
//+---- 
 int LL1=iLowest(NULL,0,MODE_LOW,median,b1-median);
 int LL2=iLowest(NULL,0,MODE_LOW,median,b2); 
//+----  
 ObjectCreate(i+"  1",OBJ_TREND,0,iTime(NULL,0,BB1),H1,iTime(NULL,0,BB2),H2);ObjectSet(i+"  1",OBJPROP_RAY,false);ObjectSet(i+"  1",OBJPROP_COLOR,DodgerBlue);if(H1<H2)ObjectMove(i+"  1",1,iTime(NULL,0,BB2-(23-T2)*(60/Period())),NormalizeDouble(H2+((H2-H1)/(BB1-BB2))*(23-T2)*(60/Period()),Digits));if(H1>H2)ObjectMove(i+"  1",1,iTime(NULL,0,BB2-(23-T2)*(60/Period())),NormalizeDouble(H2-((H1-H2)/(BB1-BB2))*(23-T2)*(60/Period()),Digits));
 ObjectCreate(i+"  2",OBJ_TREND,0,iTime(NULL,0,LL1),L1,iTime(NULL,0,LL2),L2);ObjectSet(i+"  2",OBJPROP_RAY,false);ObjectSet(i+"  2",OBJPROP_COLOR,OrangeRed);if(L1<L2)ObjectMove(i+"  2",1,iTime(NULL,0,LL2-(23-T2)*(60/Period())),L2+((L2-L1)/(LL1-LL2))*(23-T2)*(60/Period()));if(L1>L2)ObjectMove(i+"  2",1,iTime(NULL,0,LL2-(23-T2)*(60/Period())),L2-((L1-L2)/(LL1-LL2))*(23-T2)*(60/Period()));
 b1=0;b2=0;median=0;}
//+----if(H1<H2)ObjectMove(i+"  1",1,iTime(NULL,0,BB2-barsTrehd),H2+(MathAbs(H1-H2)/(BB1-BB2))*barsTrehd);if(H1>H2)ObjectMove(i+"  1",1,iTime(NULL,0,BB2-barsTrehd),H2-(MathAbs(H1-H2)/(BB1-BB2))*barsTrehd);
 }}
//+------------------------------------------------------------------+ 
int deinit(){for(int i=iBarShift(NULL,0,START,false);i>=0;i--){ObjectDelete(i+"  1");ObjectDelete(i+"  2");}}
//+------------------------------------------------------------------+