help need in code edit two horizontal lines X pips above and below at daily open

 
instead of Bid I want to put Dailyopen
ObjectCreate(LineName, OBJ_HLINE, 0, 0, Bid - pipDistance*Point);

in below "daily open" indicator code i have put horizontal lines code but instead of Bid price i want horizontal lines on daily open. try to edit but compile error. Any Help Highly appreciated Thankyou.

//*
//* my_DailyOpen_indicator


#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_style1 0
#property indicator_width1 2
#property indicator_chart_window
extern string LineName="MyLineL";
extern string LineName1="MyLineH";
extern color LineColor=Pink; 
extern color LineColor1=DodgerBlue; 
extern int LineStyle=STYLE_SOLID;
extern int LineStyle1=STYLE_SOLID;
extern int pipDistance = 5;
extern string AlertWav="alert.wav";



double TodayOpenBuffer[];
extern int TimeZoneOfData= 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
        SetIndexStyle(0,DRAW_LINE);
        SetIndexBuffer(0,TodayOpenBuffer);
        SetIndexLabel(0,"Open");
        SetIndexEmptyValue(0,0.0);
        return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
        return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int lastbar;
   int counted_bars= IndicatorCounted();
   
   if (counted_bars>0) counted_bars--;
   lastbar = Bars-counted_bars; 
   DailyOpen(0,lastbar);
   
    ObjectCreate(LineName, OBJ_HLINE, 0, 0, Bid - pipDistance*Point);
      ObjectSet(LineName, OBJPROP_STYLE, LineStyle);
      ObjectSet(LineName, OBJPROP_COLOR, LineColor);
      
      ObjectCreate(LineName1, OBJ_HLINE, 0, 0, Bid + pipDistance*Point);
      ObjectSet(LineName1, OBJPROP_STYLE, LineStyle1);
      ObjectSet(LineName1, OBJPROP_COLOR, LineColor1);
        
      double val =  ObjectGet( LineName, OBJPROP_PRICE1);
      if (Bid <= val ) PlaySound(AlertWav);
      
      double val1 =  ObjectGet( LineName1, OBJPROP_PRICE1);
      if (Bid >= val1 ) PlaySound(AlertWav);
   
   
   

   return (0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int DailyOpen(int offset, int lastbar)
{
   int shift;
   int tzdiffsec= TimeZoneOfData * 3600;
   double barsper30= 1.0*PERIOD_M30/Period();
   bool ShowDailyOpenLevel= True;
   // lastbar+= barsperday+2;  // make sure we catch the daily open              
   lastbar= MathMin(Bars-20*barsper30-1, lastbar);

        for(shift=lastbar;shift>=offset;shift--){
          TodayOpenBuffer[shift]= 0;
     if (ShowDailyOpenLevel){
       if(TimeDay(Time[shift]-tzdiffsec) != TimeDay(Time[shift+1]-tzdiffsec)){      // day change
         TodayOpenBuffer[shift]= Open[shift];         
         TodayOpenBuffer[shift+1]= 0;                                                           // avoid stairs in the line
       }
       else{
         TodayOpenBuffer[shift]= TodayOpenBuffer[shift+1];
       }
          }
   }
   return(0);
}
 
samvendor:
instead of Bid I want to put Dailyopen

in below "daily open" indicator code i have put horizontal lines code but instead of Bid price i want horizontal lines on daily open. try to edit but compile error. Any Help Highly appreciated Thankyou.

Not exactly sure what you're trying to achieve (your DailyOpen() looks complicated), but have you tried this?:

   for (int i=lastbar; i>=0; i--)
   {
      int iDBar = iBarShift(Symbol(),PERIOD_D1,Time[i]);
      TodayOpenBuffer[i] = iOpen(Symbol(),PERIOD_D1,iDBar);
   }

in place of: 

   DailyOpen(0,lastbar);
?
 
  1.       int iDBar = iBarShift(Symbol(),PERIOD_D1,Time[i]);
          TodayOpenBuffer[i] = iOpen(Symbol(),PERIOD_D1,iDBar);
    
    On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing candle values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

    The function linked to, opens a hidden chart for the symbol/TF in question (if not already open,) thus updating history, and temporarily placing the symbol on Market Watch (if not already there,) so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't also return zero on the first call.

  2. Avoid the problem, use:
    int iBOD = iBarShift(_Symbol, _Period, date(Time[i]) ); // Beginning of the Day
    TodayOpenBuffer[i] = Open[iBOD];
              Find bar of the same time one day ago - Simple Trading Strategies - MQL4 programming forum
Reason: