I'm trying to code an indicator to draw an unlocked horizontal line on the chart which the user can then move around while the indicator still knows what price the line is at currently.
Using these globals:
private double LinePrice = 0;
IHorizontalLine Line = null;
And here in OnBarUpdate:
if (Line == null)
{
Line = DrawHorizontalLine("Line1", true, Close[1], Color.White, DashStyle.Dash, 1);
Line.Locked = false;
}
LinePrice = Line.Y;
This code is working fine for my purpose, except that the line does NOT initially draw at Close[1]. Instead it draws at some random location on the chart, which is sometimes very far away from price. How can I get the line to draw at Close[1] and stay there till I move it?
Thanks!
Comment