some vertical lines in a period of 1y

 

Hi Community,

I want to write a little script who puts 2 vertical lines each Day in a period of 1 year (12:00h and 14:50h, 2010-2011)

Can sb help me please?

Thx a lot in advance!

ZarTum

 
Create an indicator
int start(){
        for (int iBar= Bars - 1 - IndicatorCounted(); iBar >= 0; iBar--){
                datetime        now = Time[iBar];
                int             TOD = now % 86400;      // Time of day
                datetime        BOD = now - TOD;        // Beginning of the day.
                #define HR1200 43200 // 12*3600
                #define HR1450 53400 // 14*3600 + 50*60
                if (TOD == HR1200 || TOD == HR1420){
                        string name = "VL" + TimeToStr(now, TIME_MINUTES);
                        VLine(name, now, RED);
                }
        }
}
void VLine(string name, datetime T0, color clr){    //  #define WINDOW_MAIN 0
    if (!Show.Objects)  return;
    if      (ObjectMove( name, 0, T0, 0 )){}
    else if (!ObjectCreate( name, OBJ_VLINE, WINDOW_MAIN, T0, 0 ))
        Alert("ObjectCreate(",name,",VLINE) failed: ", GetLastError() );
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [1] failed: ", GetLastError() );
    if (!ObjectSetText(name, TimeToStr(T0, TIME_MINUTES), 10))
        Alert("ObjectSetText(",name,") [1] failed: ", GetLastError());
}
Good on M1 or M5
 

Hi,

thx a lot but the code doesn't work

 
ZarTum:
thx a lot but the code doesn't work
  1. "Doesn't work" doesn't say anything. That wasn't a complete indicator, it was just typed in, the typos mean it wouldn't even compile. YOU must do the rest. What doesn't work? Where is your code?
  2. Minor error corrected:
    TOD = now % 86400;      // Time of day
    BOD = now - TOD;        // Beginning of the day.

 
    if (!Show.Objects)  return;
    if      (ObjectMove( name, 0, T0, 0 )){}
    else if (!ObjectCreate( name, OBJ_VLINE, WINDOW_MAIN, T0, 0 ))

The compiler doesn't get what's Show.Object and WINDOW_MAIN