two horizontal lines X pips above and below at daily open

To add comments, please log in or register
samvendor
60
samvendor  
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 by 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);
}
Marco vd Heijden
Moderator
12483
Marco vd Heijden  
ObjectMove(0,LineName,0,iTime(Symbol(),PERIOD_D1,0),0);
To add comments, please log in or register