extern color ColorMonday = Blue;
extern color ColorTuesday = MediumSeaGreen;
extern color ColorWednesday = Orange;
extern color ColorThursday = Orchid;
extern color ColorFriday = Coral;
void OnChartEvent(const int EventID, // Event ID
const long& lparam, // Parameter of type long event
const double& dparam, // Parameter of type double event
const string& sparam // Parameter of type string events
)
{
if (EventID == CHARTEVENT_CHART_CHANGE)
{
clear();
show();
}
}
void show() {
int P = Period();
if (P > PERIOD_D1) return;
string name = "";
int cnt = MathMin(Bars, PERIOD_D1/P*MaxDays);
int j=0;
if (!ShowToday) j = PERIOD_D1/P;
for (int i=j; i < cnt; i++)
{
if (TimeDayOfWeek(Time[i]) != TimeDayOfWeek(Time[i+1]))
{
name = prefix + TimeToStr(Time[i]);
int res = ObjectFind(name);
if (res == -1)
{
int day = TimeDayOfWeek(Time[i]);
if (!ShowDay[day-1]) continue;
ObjectCreate(0,name, OBJ_TEXT, 0, Time[i]+3600 , WindowPriceMin() + 50*Point);
ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_LEFT);
if(Period()<PERIOD_H4){
ObjectSetText(name, Text[day-1], FontSize, FontName, Color[day-1]);
}else{
ObjectDelete(name);
}
}
}
}
}
void clear() {
int P = Period();
if (P > PERIOD_D1) return;
string name = "";
int cnt = MathMin(Bars, PERIOD_D1/P*MaxDays);
for (int i=0; i < cnt; i++)
{
name = prefix + TimeToStr(Time[i]);
int res = ObjectFind(name);
ObjectDelete(name);
}
}