Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unwanted lines on chart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Unwanted lines on chart

    Greetings!

    I am getting unwanted lines on my chart. If i comment out the draw.lines lines of code i still get the lines drawn. I am having an issue with another part of the script and i think this is the reason. Any help would be appreciated!

    private void CalculateStructure()
    {
    if (CurrentBar < 1) return; // Ensure there is at least one bar

    for (int i = 0; i <= CurrentBar; i++)
    {
    if (CurrentBar < 10)
    {
    // For the first 10 bars, find the highest high and lowest low
    if (i == 0)
    {
    HighLevel = High[i];
    LowLevel = Low[i];
    }
    else
    {
    if (High[i] > HighLevel)
    {
    HighLevel = High[i];
    LastHHBar = HighLevel;
    }
    if (Low[i] < LowLevel)
    {
    LowLevel = Low[i];
    LastLLBar = LowLevel;
    }
    }
    }
    else
    {
    // For bars after the first 10 bars, update HighLevel and LowLevel based on closing price
    if (Close[0] > HighLevel)
    {
    HighLevel = High[0];
    LowLevel = LastLLBar;

    Draw.Line(this, "High Level" + CurrentBar, false, CurrentBar, HighLevel, CurrentBar, HighLevel, HighLvlColor, DashStyleHelper.Solid, 4);
    Draw.Line(this, "Low Level" + CurrentBar, false, CurrentBar, LastLLBar, CurrentBar, LastLLBar, LowLvlColor, DashStyleHelper.Solid, 4);
    Print($"New HH HighLevel at bar {CurrentBar}, price: {HighLevel}");
    Print($"New HH LowLevel at bar {CurrentBar}, price: {LowLevel}");
    }
    else if (Close[0] < LowLevel)
    {
    LowLevel = Low[0];
    HighLevel = LastHHBar;

    Draw.Line(this, "High Level" + CurrentBar, false, CurrentBar, LastHHBar, CurrentBar, LastHHBar, HighLvlColor, DashStyleHelper.Solid, 4);
    Draw.Line(this, "Low Level" + CurrentBar, false, CurrentBar, LowLevel, CurrentBar, LowLevel, LowLvlColor, DashStyleHelper.Solid, 4);
    Print($"New LL HighLevel at bar {CurrentBar}, price: {HighLevel}");
    Print($"New LL LowLevel at bar {CurrentBar}, price: {LowLevel}");
    }
    else
    {
    Draw.Line(this, "High Level" + CurrentBar, false, CurrentBar, HighLevel, CurrentBar, HighLevel, HighLvlColor, DashStyleHelper.Solid, 4);
    Draw.Line(this, "Low Level" + CurrentBar, false, CurrentBar, LowLevel, CurrentBar, LowLevel, LowLvlColor, DashStyleHelper.Solid, 4);
    Print($"Old HighLevel at bar {CurrentBar}, price: {HighLevel}");
    Print($"Old LowLevel at bar {CurrentBar}, price: {LowLevel}");
    }
    }
    }
    }

    region Properties
    [NinjaScriptProperty]
    [Display(Name = "Strength", Order = 1, GroupName = "Parameters")]
    public int Strength { get; set; }

    [NinjaScriptProperty]
    [Display(Name = "TextOffset", Order = 2, GroupName = "Parameters")]
    public int TextOffset { get; set; }

    [NinjaScriptProperty]
    [Display(Name = "LookBack", Order = 3, GroupName = "Parameters")]
    public int LookBack { get; set; }

    [NinjaScriptProperty]
    [Display(Name = "DTBStrength", Order = 4, GroupName = "Parameters")]
    public int DTBStrength { get; set; }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "HHcolor", Order = 5, GroupName = "Colors")]
    public Brush HHcolor { get; set; }

    [Browsable(false)]
    public string HHcolorSerializable
    {
    get { return Serialize.BrushToString(HHcolor); }
    set { HHcolor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "HLcolor", Order = 6, GroupName = "Colors")]
    public Brush HLcolor { get; set; }

    [Browsable(false)]
    public string HLcolorSerializable
    {
    get { return Serialize.BrushToString(HLcolor); }
    set { HLcolor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "LLcolor", Order = 7, GroupName = "Colors")]
    public Brush LLcolor { get; set; }

    [Browsable(false)]
    public string LLcolorSerializable
    {
    get { return Serialize.BrushToString(LLcolor); }
    set { LLcolor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "LHcolor", Order = 8, GroupName = "Colors")]
    public Brush LHcolor { get; set; }

    [Browsable(false)]
    public string LHcolorSerializable
    {
    get { return Serialize.BrushToString(LHcolor); }
    set { LHcolor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "DBcolor", Order = 9, GroupName = "Colors")]
    public Brush DBcolor { get; set; }

    [Browsable(false)]
    public string DBcolorSerializable
    {
    get { return Serialize.BrushToString(DBcolor); }
    set { DBcolor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "DTcolor", Order = 10, GroupName = "Colors")]
    public Brush DTcolor { get; set; }

    [Browsable(false)]
    public string DTcolorSerializable
    {
    get { return Serialize.BrushToString(DTcolor); }
    set { DTcolor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "HighLvlColor", Order = 11, GroupName = "Colors")]
    public Brush HighLvlColor { get; set; }

    [Browsable(false)]
    public string HighLvlColorSerializable
    {
    get { return Serialize.BrushToString(HighLvlColor); }
    set { HighLvlColor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "LowLvlColor", Order = 12, GroupName = "Colors")]
    public Brush LowLvlColor { get; set; }

    [Browsable(false)]
    public string LowLvlColorSerializable
    {
    get { return Serialize.BrushToString(LowLvlColor); }
    set { LowLvlColor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [Display(Name = "TextFont", Order = 13, GroupName = "Fonts")]
    public SimpleFont TextFont { get; set; }
    #endregion
    }
    }​

    #2
    Hello TheTechnician86, In the code you provided there are multiple Draw.Line statements, did you comment them all out? The code here does not have any comments so this code specifically should be drawing lines.

    Comment


      #3
      Jesse

      thank you for your response. I commented out those draw.lines but I still get lines drawn on the chart. In order to remove the lines complete I have to comment out the value[0][0] lines as well.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kowtko517, 05-21-2023, 12:35 PM
      9 responses
      7,681 views
      0 likes
      Last Post pradeeplrao  
      Started by Apm123, Today, 05:14 AM
      1 response
      28 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by mlarocco, 06-20-2025, 11:12 AM
      1 response
      72 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by futurenow, 12-06-2021, 05:49 PM
      19 responses
      1,040 views
      0 likes
      Last Post Redders
      by Redders
       
      Started by mathfrick2023, 05-08-2025, 12:51 PM
      8 responses
      156 views
      0 likes
      Last Post Yogaman
      by Yogaman
       
      Working...
      X