This is a simple session indicator that prints the range up to 1 Hour chart. I'm trying to make it work on higher time frames so I've changed the period to W1 but it still doesn't print the lines past the H1.
Anyone willing to help and tweak it?
Anyone willing to help and tweak it?
Inserted Code
//+----------------------------------------------------------------------------+ //| i-AnyRange.mq4 | //| Ким Игорь В. aka KimIV | //| http://www.kimiv.ru | //| | //| 17.11.2006 Индикатор диапазонов произвольных временных интервалов. | //+----------------------------------------------------------------------------+ #property copyright "Ким Игорь В. aka KimIV" #property link "http://www.kimiv.ru" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 LightBlue #property indicator_color2 Salmon #property indicator_width1 2 #property indicator_width2 2 //------- Внешние параметры индикатора ----------------------------------------- extern string Time1 = "02:00"; // Временная точка 1 extern string Time2 = "07:00"; // Временная точка 2 extern int nDays = 0; // Количество дней обсчёта (0-все) //------- Глобальные переменные ------------------------------------------------ //------- Поключение внешних модулей ------------------------------------------- //------- Буферы индикатора ---------------------------------------------------- double dBuf0[], dBuf1[]; //+----------------------------------------------------------------------------+ //| Custom indicator initialization function | //+----------------------------------------------------------------------------+ void init() { SetIndexBuffer (0, dBuf0); SetIndexEmptyValue(0, EMPTY_VALUE); SetIndexStyle (0, DRAW_LINE); SetIndexBuffer (1, dBuf1); SetIndexEmptyValue(1, EMPTY_VALUE); SetIndexStyle (1, DRAW_LINE); } //+----------------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+----------------------------------------------------------------------------+ void deinit() { Comment(""); } //+----------------------------------------------------------------------------+ //| Custom indicator iteration function | //+----------------------------------------------------------------------------+ void start() { double up, dn; int i, LoopBegin, kd=0, nb1, nb2, nd=0; string sdt; if (Period()==PERIOD_W1) { Comment("Indicator i-AnyRange works on TFs lower H1"); return; } else Comment(""); if (nDays==0) LoopBegin=Bars-10; else LoopBegin=nDays*Period(); LoopBegin=MathMin(Bars-10, LoopBegin); for (i=0; i<LoopBegin; i++) { if (nd!=TimeDay(Time[i])) { kd++; if (kd>nDays && nDays>0) return; sdt=TimeToStr(Time[i], TIME_DATE); nb1=iBarShift(NULL, 0, StrToTime(sdt+" "+Time1)); nb2=iBarShift(NULL, 0, StrToTime(sdt+" "+Time2)); if (nb1>nb2) { up=High[iHighest(NULL, 0, MODE_HIGH, nb1-nb2, nb2)]; dn=Low [iLowest (NULL, 0, MODE_LOW , nb1-nb2, nb2)]; } if (nb2>nb1) { up=High[iHighest(NULL, 0, MODE_HIGH, nb2-nb1, nb1)]; dn=Low [iLowest (NULL, 0, MODE_LOW , nb2-nb1, nb1)]; } } if ((nb1>=i && i>=nb2) || (nb2>=i && i>=nb1)) { dBuf0[i]=up; dBuf1[i]=dn; } else { dBuf0[i]=EMPTY_VALUE; dBuf1[i]=EMPTY_VALUE; } nd=TimeDay(Time[i]); } } //+----------------------------------------------------------------------------+