
  #property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 White
#property indicator_color2 Yellow
#property indicator_color3 Red
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_style1 1
#property indicator_style2 0
#property indicator_style3 0

//---- buffers


double monthlyopen[];
double dailyopen[];
double weeklyopen[];
double line;
double m,d,w;
extern bool ShowPrice = FALSE;


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,dailyopen);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(1,weeklyopen);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(2,monthlyopen);

string mopen, dopen, wopen;
dopen = "Daily Open";
wopen = "Weekly Open";
mopen = "Monthly Open";

IndicatorShortName(mopen);
IndicatorShortName(dopen);
IndicatorShortName(wopen);

SetIndexLabel(0,dopen);
SetIndexLabel(1,wopen);
SetIndexLabel(2,mopen);

SetIndexDrawBegin(0,1);
//SetIndexDrawBegin(1,1);

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//ObjectDelete("Weekly Open");
//ObjectDelete("Daily Open");

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit, i;
string l_name_24;
string l_name_32;
string l_name_40;
//----
if(counted_bars==0)
{//0
//d=Period();
//if (d>240)return(-1);
ObjectCreate("Weekly Open",OBJ_HLINE,0,0,0);
ObjectCreate("Daily Open",OBJ_HLINE,0,0,0);
ObjectCreate("Monthly Open",OBJ_HLINE,0,0,0);

}//0


if(counted_bars<0) return(-1);

limit=(Bars-counted_bars)-1;

for(i=limit; i>=0; i--)
{//0
if(1==TimeDayOfWeek(Time[i]) && 1!=TimeDayOfWeek(Time[i+1]))
{//1
w=Open[i];
ObjectMove("Weekly Open",0,Time[i],line);
}//2
if (TimeDay(Time[i]) !=TimeDay(Time[i+1]))
{//3
d=Open[i];
ObjectMove("Daily Open",0,Time[i],line);
}//3
if (TimeMonth(Time[i]) !=TimeMonth(Time[i+1]))
{//3
m=Open[i];
ObjectMove("Monthly Open",0,Time[i],line);
}//3 
weeklyopen[i]=w;
dailyopen[i]=d;
monthlyopen[i]=m;
}//0

if (ShowPrice) {
l_name_24 = "Daily Open";
ObjectDelete(l_name_24);
ObjectCreate(l_name_24, OBJ_ARROW, 0, 0, 0);
ObjectSet(l_name_24, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
ObjectSet(l_name_24, OBJPROP_COLOR, Lime);
ObjectSet(l_name_24, OBJPROP_TIME1, Time[0]);
ObjectSet(l_name_24, OBJPROP_PRICE1, dailyopen[0]);
l_name_32 = "Weekly Open";
ObjectDelete(l_name_32);
ObjectCreate(l_name_32, OBJ_ARROW, 0, 0, 0);
ObjectSet(l_name_32, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
ObjectSet(l_name_32, OBJPROP_COLOR, Fuchsia);
ObjectSet(l_name_32, OBJPROP_TIME1, Time[0]);
ObjectSet(l_name_32, OBJPROP_PRICE1, weeklyopen[0]);
l_name_40 = "Monthly Open";
ObjectDelete(l_name_40);
ObjectCreate(l_name_40, OBJ_ARROW, 0, 0, 0);
ObjectSet(l_name_40, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
ObjectSet(l_name_40, OBJPROP_COLOR, Aqua);
ObjectSet(l_name_40, OBJPROP_TIME1, Time[0]);
ObjectSet(l_name_40, OBJPROP_PRICE1, monthlyopen[0]);

}
return(0);
}
//+------------------------------------------------------------------+