I have read all the posts I can find on this but I still can't get it to work. I am trying to draw a line at my stoploss price, which is based on ATR, and quit drawing the line when the trade is over. I have tried every combination I can think of but none have drawn the line correctly. Can someone please tell me what's wrong with my code? Thanks
protected override void OnBarUpdate()
{
int StopLoss = Convert.ToInt32(Math.Round( ATR(ATRStopPeriod)[0] * ATRStopMulti / TickSize));
#region Stoploss reset, ATR Stop set, & ATR Trail
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss("V4 L2",CalculationMode.Ticks, StopLoss, false);
}
if (Position.MarketPosition != MarketPosition.Flat)
{
//Draw Stop Line
DrawLine("StopLoss"+ CurrentBar, false, BarsSinceEntry("V4 L2"), StopLoss, 0, StopLoss, Color.Red, DashStyle.Solid,2);
}
#endregion


Comment