Hi!
I try to make a trendline that starts at the current bar and is draw 20 bars in the future, I tried to use this code below but it do not work,
Code is Mql5.
Any suggestions?
ObjectDelete(0,"H5"); ObjectCreate(0,"H5",OBJ_TREND,0,TimeCurrent(),H5,time[-20],H5);
ObjectSetInteger(0,"H5",OBJPROP_COLOR,clrGreen);
ObjectSetInteger(0,"H5",OBJPROP_STYLE,STYLE_SOLID);
ObjectSetInteger(0,"H5",OBJPROP_WIDTH,2); ObjectSetInteger(0,"H5",OBJPROP_BACK,false);
ObjectSetString(0,"H5",OBJPROP_TEXT,"H5 LB Target");
ObjectSetDouble(0,"H5",OBJPROP_PRICE,H5);
Thanks,
Kim
The sample code belongs to me.
You have to review the manual from the beginning: https://www.mql5.com/en/docs/constants/objectconstants/enum_object_property#enum_object_property_integer

- www.mql5.com
Ok, but I think most of the "SetInteger" code is working, the problem is how to obtain the time/date for the 20th bar.
So this part of the code:
ObjectCreate(0,"H5",OBJ_TREND,0,TimeCurrent(),H5,time[-20],H5);
How about:
ObjectCreate(0,"H5",OBJ_TREND,0,TimeCurrent(),H5,TimeCurrent()+20*Period()*60,H5);And as an alternative (although not equal to TimeCurrent()), Time[0] will give you the exact start time of the latest bar...
Can't be done.
- Time[0]+20*Period()*60 will not work. @Seng
Joo Thio It assumes that the value of the enumeration (ENUM_TIMEFRAMES) equals the period in minutes.
On MT
5 ENUM_TIMEFRAMES values are not the period in minutes.
Use EnumToString(TF[i]) to see the string representation of the time frame.
Use PeriodSeconds(TF[i]) to see the duration of the time frame.
Why calculations of period()_value are different? (over 30 minutes) What's Burg? - Indices - Technical Indicators - MQL5 programming forum - Time[0]+20*PeriodSeconds() will not work. It assumes that all bars exist in the future. What if there are
no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts,
think weekend, market holiday (country and broker specific.) requires knowledge of when your broker stops and starts (not necessary
the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles
No candle if open = close ? - MQL4 programming forum - № 2 is only an approximation, and you can update the time each new bar.
Been there, done that. Need c o f f e e.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi!
I try to make a trendline that starts at the current bar and is draw 20 bars in the future, I tried to use this code below but it do not work, Code is Mql5.
Any suggestions?
ObjectDelete(0,"H5"); ObjectCreate(0,"H5",OBJ_TREND,0,TimeCurrent(),H5,time[-20],H5);
ObjectSetInteger(0,"H5",OBJPROP_COLOR,clrGreen); ObjectSetInteger(0,"H5",OBJPROP_STYLE,STYLE_SOLID);
ObjectSetInteger(0,"H5",OBJPROP_WIDTH,2); ObjectSetInteger(0,"H5",OBJPROP_BACK,false);
ObjectSetString(0,"H5",OBJPROP_TEXT,"H5 LB Target"); ObjectSetDouble(0,"H5",OBJPROP_PRICE,H5);
Thanks,
Kim