Skleciłem sobie taki wskaźnik z dwóch innych .
Rysuje on dwie linie pionowe na wykresie o godzinie 2 i 7 GMT od dnia bieżącego do NumberOfDays wstecz .
Niestety rysuje także linię pionową na zakończeniu piątkowej sesji FX .(AM ok 20:45 GMT)

Może ktoś wie co może być przyczyną takiego zachowania ?
Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| VLine.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property show_inputs
#property indicator_chart_window
extern int NumberOfDays = 10;
extern string hour = "02:00";
extern int width = 1;
extern color Color = IndianRed;
extern string hour2 = "07:00";
extern int width2 = 1;
extern color Color2 = IndianRed;
//-------------------------------------------------------------------+
int init()
{
int count = 0 ;
int i=0;
datetime timecur = TimeCurrent();
for (i=0; i<NumberOfDays; i++) {
ObjectCreate("Time_Vertical_Line_"+Period()+count, OBJ_VLINE, 0, timecur, 0);
count++ ;
ObjectCreate("Time_Vertical_Line2_"+Period()+count, OBJ_VLINE, 0, timecur, 0);
count++ ;
}
return(0);
}
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
int count = 0 ;
int i=0;
datetime timecur = TimeCurrent();
datetime time ;
datetime time2 ;
//count = 0 ;
for (i = 0 ; i<NumberOfDays; i++) {
time = StrToTime(TimeToStr(timecur, TIME_DATE) + " " + hour );
time2 = StrToTime(TimeToStr(timecur, TIME_DATE) + " " + hour2 );
ObjectSet("Time_Vertical_Line_"+Period()+count,OBJPROP_TIME1,time);
ObjectSet("Time_Vertical_Line_"+Period()+count, OBJPROP_WIDTH, width);
ObjectSet("Time_Vertical_Line_"+Period()+count, OBJPROP_COLOR, Color);
ObjectSet("Time_Vertical_Line_"+Period()+count, OBJPROP_BACK, true);
count++ ;
ObjectSet("Time_Vertical_Line2_"+Period()+count,OBJPROP_TIME1,time2);
ObjectSet("Time_Vertical_Line2_"+Period()+count, OBJPROP_WIDTH, width2);
ObjectSet("Time_Vertical_Line2_"+Period()+count, OBJPROP_COLOR, Color2);
ObjectSet("Time_Vertical_Line2_"+Period()+count, OBJPROP_BACK, true);
count++ ;
timecur=decrementTradeDate(timecur);
while (TimeDayOfWeek(timecur) > 5) timecur = decrementTradeDate(timecur);
// to to nie wiem do czego
}
//----as "yyyy.mm.dd hh:mi".
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
//----
int count = 0 ;
int i=0;
for (i=0; i<NumberOfDays; i++)
{
if (ObjectFind("Time_Vertical_Line_"+Period()+count) > -1)
{
ObjectDelete("Time_Vertical_Line_"+Period()+count);
}
count++;
if (ObjectFind("Time_Vertical_Line2_"+Period()+count) > -1)
{
ObjectDelete("Time_Vertical_Line2_"+Period()+count);
}
count++;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Decrement Date to draw objects in the past |
//+------------------------------------------------------------------+
datetime decrementTradeDate (datetime dtTimeDate) {
int iTimeYear=TimeYear(dtTimeDate);
int iTimeMonth=TimeMonth(dtTimeDate);
int iTimeDay=TimeDay(dtTimeDate);
int iTimeHour=TimeHour(dtTimeDate);
int iTimeMinute=TimeMinute(dtTimeDate);
iTimeDay--;
if (iTimeDay==0) {
iTimeMonth--;
if (iTimeMonth==0) {
iTimeYear--;
iTimeMonth=12;
}
// Thirty days hath September...
if (iTimeMonth==4 || iTimeMonth==6 || iTimeMonth==9 || iTimeMonth==11) iTimeDay=30;
// ...all the rest have thirty-one...
if (iTimeMonth==1 || iTimeMonth==3 || iTimeMonth==5 || iTimeMonth==7 || iTimeMonth==8 || iTimeMonth==10 || iTimeMonth==12) iTimeDay=31;
// ...except...
if (iTimeMonth==2) if (MathMod(iTimeYear, 4)==0) iTimeDay=29; else iTimeDay=28;
}
return(StrToTime(iTimeYear + "." + iTimeMonth + "." + iTimeDay + " " + iTimeHour + ":" + iTimeMinute));
}
//+------------------------------------------------------------------+