index-1 and .OpenTime.Last(1) getting different drawing position Since Christmas

Created at 27 Dec 2016, 02:50
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
DE

deansi

Joined 30.10.2014

index-1 and .OpenTime.Last(1) getting different drawing position Since Christmas
27 Dec 2016, 02:50


Ive been working on an Indicator that draws 4 short lines above each bar on the chart, and ever since the christmas weekend it displays them incorrectly at the wrong bar, ie offset back 1 more bar than it should be. So I looked at whats different about this indicator than most and its just that it uses the DateTime way of pointing at where to draw at, where as most other indicatos use the index pointer way. So I changed the code where Id had:

MarketSeries.OpenTime.Last(1)

and changed it to 

index-1

and that fixes it, unfortunately it still looks like a bug and this may cause havoc with a lot of other indicators and maybe even cbots. Examle of the line of code below, unless Im mistaken these 2 lines of code should draw in exactly the same place, but for some reason after this weekend they dont.

///So the line of code Ive changed goes from this:
ChartObjects.DrawLine("Ck T"+ MarketSeries.OpenTime.Last(1).ToString(), index-1, MarketSeries.High.Last(1) + (dtr.Result.Last(1)*0.1), index-1, MarketSeries.High.Last(1) + (dtr.Result.Last(1)*0.15), chkTCol, 3, LineStyle.Solid);
To This:
ChartObjects.DrawLine("Ck T"+ MarketSeries.OpenTime.Last(1).ToString(), index-1, MarketSeries.High.Last(1) + (dtr.Result.Last(1)*0.1), index-1, MarketSeries.High.Last(1) + (dtr.Result.Last(1)*0.15), chkTCol, 3, LineStyle.Solid);

 

 

 


@deansi
Replies

deansi
27 Dec 2016, 02:53

RE:

Sorry my example code was duplicate, it should have been:

///So the line of code Ive changed goes from this:
ChartObjects.DrawLine("Ck T"+ MarketSeries.OpenTime.Last(1).ToString(), MarketSeries.OpenTime.Last(1), MarketSeries.High.Last(1) + (dtr.Result.Last(1)*0.1), MarketSeries.OpenTime.Last(1), MarketSeries.High.Last(1) + (dtr.Result.Last(1)*0.15), chkTCol, 3, LineStyle.Solid);
To This:
ChartObjects.DrawLine("Ck T"+ MarketSeries.OpenTime.Last(1).ToString(), index-1, MarketSeries.High.Last(1) + (dtr.Result.Last(1)*0.1), index-1, MarketSeries.High.Last(1) + (dtr.Result.Last(1)*0.15), chkTCol, 3, LineStyle.Solid);

 


@deansi