You can use the following code to draw a line from the C# NT strategy...
// Red SL Line
str_SLLineTag = "StopLoss"
ILine DrawLine_objSL;
DrawLine_objSL = (ILine) DrawHorizontalLine(str_SLLineTag, false,
GetCurrentAsk() + (int_InitSL_Ticks * TickSize), Color.Red, DashStyle.DashDot,3);
DrawLine_objSL.Locked = false;
It returns an obj ILine variable called DrawLine_objSL and then it sets its Locked property to false.
Since the line is not "locked" you can now moved it around on the chart using your mouse.
...
You can use these routines to Get or Set the price level of the StopLoss line...
// Initial Price formatting string
str_PriceFormat = Regex.Replace(((decimal)TickSize).ToString(),"([\\d])","0");
str_PriceFormat = Regex.Replace(str_PriceFormat,",", ".");
vSetLinePrice("StopLoss", 19675);
double dblSL_LinePrice = dblGetLinePrice("StopLoss");
private void vSetLinePrice(string strTag, double dblPrice)
{
// Set ILine Price
double dbl_tmpLinePrice;
ILine obj_Line = (ILine) DrawObjects[strTag];
if (obj_Line != null)
{
obj_Line.StartY = dblPrice;
}
}
private double dblGetLinePrice(string strTag)
{
// Get ILine Price
double dbl_tmpLinePrice;
ILine obj_Line = (ILine) DrawObjects[strTag];
if (obj_Line == null) {dbl_tmpLinePrice = -1.0;}
else
{
dbl_tmpLinePrice = Instrument.MasterInstrument.Round2TickSize(Convert .ToDouble(obj_Line.StartY.ToString(str_PriceFormat )));
}
return(dbl_tmpLinePrice);
}
Comment