|
//--- strict compilation mode #property strict #property copyright "© 2006 RickD" #property link "www.fxstrategy.ca" #property version "v1.1" #property indicator_chart_window #property indicator_buffers 0 extern int MaxDays = 20; extern int FontSize = 8; extern string FontName = "Verdana"; extern string __2__ = ""; //------------------------------------------------------------------------------------------------------ extern string Text1 = "星期一"; extern string Text2 = "星期二"; extern string Text3 = "星期三"; extern string Text4 = "星期四"; extern string Text5 = "星期五"; extern string __3__ = ""; //------------------------------------------------------------------------------------------------------ extern color ColorMonday = Blue; extern color ColorTuesday = MediumSeaGreen; extern color ColorWednesday = Orange; extern color ColorThursday = Orchid; extern color ColorFriday = Coral; extern string __4__ = ""; //------------------------------------------------------------------------------------------------------ extern bool ShowToday = true; extern string __5__ = ""; //------------------------------------------------------------------------------------------------------ extern bool ShowMonday = true; extern bool ShowTuesday = true; extern bool ShowWednesday = true; extern bool ShowThursday = true; extern bool ShowFriday = true; string Text[5]; color Color[5]; bool ShowDay[5]; string prefix = "5days_"; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void init() { Text[0] = Text1; Text[1] = Text2; Text[2] = Text3; Text[3] = Text4; Text[4] = Text5; Color[0] = ColorMonday; Color[1] = ColorTuesday; Color[2] = ColorWednesday; Color[3] = ColorThursday; Color[4] = ColorFriday; ShowDay[0] = ShowMonday; ShowDay[1] = ShowTuesday; ShowDay[2] = ShowWednesday; ShowDay[3] = ShowThursday; ShowDay[4] = ShowFriday; clear(); show(); } void deinit() { clear(); } void start() { show(); } 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); } } |
指标源码库