is it possible to drawn trendlines in "future"? So far I was always drawing in "history". e.g. from current candle to candle[5] before,but now I would like to draw line (constant) for next N (e.g. 5) candles. Is that possible?
From TrendLine.Create (Create(DTPoint, DTPoint)) it looks like I need date in future, so Ideally if I can get BarDateTime from next Nth candle (BarDateTime[-5] or something like that) Is that possible?
Other option would probably be to draw long line and then cut it off once Nth candle reached.
Thanks
Can you help answer these questions from other members on futures io?
Depending on the bar type you are working with, you could calculate the end DateTime of your trendline by adding a TimeSpan which corresponds to five times the duration of your bar span to your start DateTime to calculate the end point.
Another idea could be using Barnumbers and BNPoints instead. What you mentioned in your last sentence would work as well i.e. moving the end point with every new bar for five bars.
Thanks, BNPoints looks exactly like a way to go. However, there is something weird with it. I had a look at the definition of Trendline, there is a nice example how to use BNPoints - so I take that and apply to my case - something like this (simplified):
If LastBarOnChart then
Begin
myBNPoint1 = BNPoint.Create(barnumber,4000);
myBNPoint2 = BNPoint.Create(barnumber+10,4000);
MyTL = TrendLine.Create( myBNPoint1, myBNPoint2 ) ;
MyTL.ExtRight = False ;
DrawingObjects.Add( MyTL ) ;
End;
TrendLine is plotted but it is shifted to the left. If I add debug prints of myBNPoint1, it refers to the correct barnumber&price, even if I change barnumbers so that line is plotted in history - BNPoints seem to be correct but the line is shifted.
Funny thing is that TrendLine is shifted always by 23 candles, so if I add some magic_constant=23 there:
mag_const=23;
myBNPoint1 = BNPoint.Create(barnumber+mag_const,4000);
myBNPoint2 = BNPoint.Create(barnumber+mag_const+10,4000);
It works as expected. However, I would like to avoid Bulgarian constants in my code
when you refer to the BNPoint class description in the help file it will become clear that the maxbarsback value for a study must be included since a BNPoint refers to the absolute bar index (zero-based) of the collection of bars in a chart.
Regards,
ABCTG
The following user says Thank You to ABCTG for this post: