Price Data Components
Series array that contains open time of each bar
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Open_Day
//+------------------------------------------------------------------+
//|                                                   Open_day_price |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

//inputs
int    DayNow=0,Day_of_week=0;
//buffers
double Open_Day_Buff[];
//+------------------------------------------------------------------+
double open_week,open_day;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   if(Period()>240)
     {
      Print("ÒÔ äîëæåí áûòü ìåíüøå Ä1!");
      return(-1);
     }
   SetIndexBuffer(0,Open_Day_Buff);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexLabel(0," Open day price ");
   IndicatorShortName(" Open day price ");
      SetIndexEmptyValue(0,EMPTY_VALUE);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int i=Bars-counted_bars;
   if(counted_bars==0) i--;

   while(i>=0)
     {
      int bar_today_D1=TimeDayOfYear(Time[iBarShift(Symbol(),0,iTime(Symbol(),0,i),true)]);
      if(bar_today_D1!=DayNow)// óñëîâèå  äëÿ íîâîãî äíÿ
        {
         DayNow=bar_today_D1;
         open_day=Open[i];//÷èòàåì öåíó îòêðûòèå_äíÿ íà Ä1
        }
      ////////
      int day_off_week=TimeDayOfWeek(Time[iBarShift(Symbol(),0,iTime(Symbol(),0,i),true)]);
      if(day_off_week!=Day_of_week)// óñëîâèå  äëÿ íîâîãî äíÿ
        {
         Day_of_week=day_off_week;
         open_week=Open[i];//÷èòàåì öåíó îòêðûòèå_äíÿ íà Ä1
        }
      //////////
      Open_Day_Buff[i]=open_day;
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments