This's continue from this thread: https://www.mql5.com/en/forum/256040
From that thread it can draw vertical line from past date into current date but it can not draw to future date.
I've been tried with this code but nothing happen:
Can someone suggest the changes?
Thanks for your help!
https://docs.mql4.com/constants/objectconstants/enum_object/obj_cycles

- docs.mql4.com
Like this.
#property strict #property indicator_chart_window #include <ChartObjects\ChartObjectsLines.mqh> #include <Arrays\List.mqh> input int InpNumBars=100; CList lines; //+------------------------------------------------------------------+ int OnInit() { for(int i=1;i<InpNumBars+1;i++) { CChartObjectVLine *line = new CChartObjectVLine(); line.Create( ChartID(), //this chart "line_"+string(i), //unique name 0, //no sub-window Time[0] + i * PeriodSeconds(_Period)//time in the future ); lines.Add(line); } return INIT_SUCCEEDED; } //+------------------------------------------------------------------+ int start(){ return 0; }
Like this.
Thank you nicholi shen, I will try it.
your line always "moving".
I don't know if that is OP intention?
OP needs to implement his own logic, I'm just here to demonstrate how to draw objects in the future.
Btw I am open for another solution rather than my logic.
Here's the update code but still nothing happen.
extern int FutureBars=100; for(int i=1; i<FutureBars+1; i++) { datetime dailyTimefuture=iTime(Symbol(), PERIOD_D1, Time[0] + i * PeriodSeconds(_Period)); MqlDateTime dt_structfuture; TimeToStruct(dailyTimefuture, dt_structfuture); if(dt_structfuture.day < 14) continue; if(dt_structfuture.day >= 14) { dt_structfuture.day = 14; dailyTimefuture = Time[iBarShift(_Symbol, PERIOD_CURRENT, StructToTime(dt_structfuture))]; } string namefuture=TimeToStr(dailyTimefuture)+" Time_Vertical_Line_Future"; if(ObjectFind(0,namefuture)<0) { if(!ObjectCreate(0,namefuture,OBJ_VLINE,0,dailyTimefuture,0)) Print("Fail to draw the line ERROR CODE : ",GetLastError()); ObjectSet(namefuture,OBJPROP_WIDTH,widthLine); ObjectSet(namefuture,OBJPROP_COLOR,colorLineQuarter); ObjectSet(namefuture,OBJPROP_BACK,true); } }
Here's the update code but still nothing happen.
The Time array only goes to the current bar. You need to specify the exact time in the future you want the line drawn. See my example above.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I can draw a vertical line from past date into current date but how to draw a vertical line into future date?
I've been tried with this code but nothing happen:
Can someone suggest the changes?
Thanks for your help!