Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    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 David Hill, 07-18-2024, 07:41 AM
      4 responses
      24 views
      0 likes
      Last Post David Hill  
      Started by aban1alpha, Today, 02:01 PM
      0 responses
      2 views
      0 likes
      Last Post aban1alpha  
      Started by jaybedreamin, Today, 01:08 PM
      0 responses
      2 views
      0 likes
      Last Post jaybedreamin  
      Started by Rheiverson, 07-18-2024, 04:28 PM
      2 responses
      19 views
      0 likes
      Last Post Rheiverson  
      Started by p1kn1t, Today, 11:32 AM
      0 responses
      12 views
      0 likes
      Last Post p1kn1t
      by p1kn1t
       
      Working...
      X