I am trying to get price at the current bar by below:
private bool getTLYByX(ChartAnchor start, ChartAnchor end, Bars bars, DateTime t0, double x0,
ChartPanel panel, ChartControl chartControl, ChartScale chartScale, bool useEndPointX,
ref Point startPoint, ref Point endPoint, ref Point extPoint, ref double priceT0)
{
if ((start == null) || (end == null) || (bars == null) || (panel == null) || (chartControl == null) || (chartScale == null))
{
return false;
}
try
{
double startIdx = chartControl.GetSlotIndexByTime(start.Time);
double endIdx = chartControl.GetSlotIndexByTime(end.Time);
double price0 = start.Price;
double price1 = end.Price;
DateTime time0 = start.Time;
DateTime time1 = end.Time;
// Get price at t0
double startBar = bars.GetBar(start.Time);
double endBar = bars.GetBar(end.Time);
double curBar = bars.GetBar(t0);
priceT0 = price0 + (price1 - price0) * (curBar - startBar) / (endBar - startBar);
but when I am printing priceT0, it prints different value than the acutal TL end point drawn on the chart.
I am trying to pin point where the trend line on the current bar to capture when price crosses above or below that point.
I think, I am making some mistake here, any suggestion will be highly apprecited.
Comment