|
本帖最后由 我家就在小水沟 于 2019-5-25 22:59 编辑
#property indicator_chart_window
extern int InputTimeZone = 6;//自己所在的时区
extern int ChartTimeZone = 1;//平台所在的时区
extern int LookBackDays = 2000;//向前画的天数
extern string KeyTimePoints = "06:00,11:30,13:30,15:30,21:00,04:00";//自己所在时区的时间,用逗号分开
extern color LineColor = Aqua;
extern int LineStyle = 2;
extern int LineWidth = 1;
extern bool DrawInBackground = TRUE;
int g_day_of_week_112 = -1;
int g_bars_116 = 0;
int init() {
return (0);
}
int deinit() {
string l_name_8;
int l_objs_total_0 = ObjectsTotal();
for (int l_objs_total_4 = l_objs_total_0; l_objs_total_4 >= 0; l_objs_total_4--) {
l_name_8 = ObjectName(l_objs_total_4);
if (StringSubstr(l_name_8, 0, 8) == "VertLine") ObjectDelete(l_name_8);
}
return (0);
}
int start() {
int lia_4[30];
bool li_8;
int li_12;
int li_16;
int l_index_20;
string l_time2str_24;
int l_count_32;
string ls_36;
int li_44;
int li_0 = TimeCurrent() + 3600 * (InputTimeZone - ChartTimeZone);
if (TimeDayOfWeek(li_0) != g_day_of_week_112 || Bars - g_bars_116 > 1) {
g_day_of_week_112 = TimeDayOfWeek(li_0);
g_bars_116 = Bars;
li_8 = TRUE;
li_12 = 0;
l_index_20 = 0;
while (TimeDayOfWeek(li_0) == 0 || TimeDayOfWeek(li_0) == 6) li_0 += 86400;
l_time2str_24 = TimeToStr(li_0, TIME_DATE);
while (li_8) {
l_index_20++;
li_16 = StringFind(KeyTimePoints, ",", li_12);
if (li_16 == -1) {
li_16 = StringLen(KeyTimePoints);
li_8 = FALSE;
}
lia_4[l_index_20] = StrToTime(l_time2str_24 + " " + StringSubstr(KeyTimePoints, li_12, li_16 - li_12));
li_12 = li_16 + 1;
}
l_count_32 = 0;
for (int l_count_48 = 0; l_count_48 < LookBackDays; l_count_48++) {
while (TimeDayOfWeek(li_0 - 86400 * l_count_32) == 0 || TimeDayOfWeek(li_0 - 86400 * l_count_32) == 6) l_count_32++;
for (int li_52 = 1; li_52 <= l_index_20; li_52++) {
ls_36 = "VertLine" + l_count_48 + li_52 + " " + TimeToStr(lia_4[li_52], TIME_MINUTES);
li_44 = lia_4[li_52] - 86400 * l_count_32 - 3600 * (InputTimeZone - ChartTimeZone);
DrawLine(ls_36, li_44);
}
l_count_32 += 1;
}
}
return (0);
}
void DrawLine(string a_name_0, int a_datetime_8) {
if (ObjectFind(a_name_0) != 0) ObjectCreate(a_name_0, OBJ_VLINE, 0, a_datetime_8, 0);
else ObjectMove(a_name_0, 0, a_datetime_8, 0);
ObjectSet(a_name_0, OBJPROP_STYLE, LineStyle);
ObjectSet(a_name_0, OBJPROP_COLOR, LineColor);
ObjectSet(a_name_0, OBJPROP_WIDTH, LineWidth);
ObjectSet(a_name_0, OBJPROP_BACK, DrawInBackground);
} |
|