Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with removing rays

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

    Need help with removing rays

    Hi,

    My indicator is, by design, to draw rays when condition is true but I have too many lines and am trying to reduce the clutter by removing old lines. I thought the easiest way would be by using a list to remove the older ones. While everything seems to be compiling without errors, something else may be wrong with the list. I tried capping it to 10 rays but I'm still getting more than 50 rays! Can you please have a look to see what is wrong or how I should go about resolving this issue? The code is below:-

    Code:
    if (CurrentBar < (level*2 + 10)) return;
    
    if( DemandLineCount == DemandLineMaxCount )
    {
    DemandLines.RemoveAt(DemandLines.Count-1);
    }
    
    // Identify the first pivot low
    if((Math.Min(Low[1],Close[2]) < Math.Min(Low[0],Close[1])) && (Math.Min(Low[1],Close[2]) < Math.Min(Low[2], Close[3])))
    {
    DemandPoint0 = Math.Min(Low[1],Close[2]);
    DemandPoint0Y = CurrentBar-level;
    // Draw.Dot(this, "DPDot"+CurrentBar, true, 1, DemandPoint0, Brushes.Red, true);
    // Print(Time[0].ToString());
    // Print("CurrentBara = " + CurrentBar.ToString());
    }
    // Hunting for a lower pivot low that has already occurred which meets the same pivot low condition and to draw a ray connecting the 2 points
    for( int x = 1; x <= Math.Min(CurrentBar-4, 50); x++)
    {
    if ((Math.Min(Low[x], Close[x+1]) < Math.Min(Low[x-1], Close[x])) && (Math.Min(Low[x], Close[x+1]) < Math.Min(Low[x+1], Close[x+2])))
    {
    if (Math.Min(Low[x], Close[x+1]) < DemandPoint0)
    {
    DemandPoint1 = Math.Min(Low[x], Close[x+1]);
    DemandPoint1Y = x;
    string drawTag = "DPL" + CurrentBar;
    Draw.Ray(this, drawTag, true, DemandPoint1Y, DemandPoint1, CurrentBar - DemandPoint0Y , DemandPoint0, Brushes.Pink, DashStyleHelper.Solid, 1);
    DemandLineCount++;
    DemandLines.Add(drawTag);
    Print(Time[0].ToString());
    Print("drawtag = " + drawTag);
    // Print("x =" + x.ToString());
    // Print("low[x] = " + Low[x].ToString());
    // Print("low[1] = " + Low[1].ToString());
    // Print("CurrentBar = " + CurrentBar.ToString());
    // Print("DemandPoint0 = " + DemandPoint0.ToString());
    // Print("DemandPoint0Y = " + DemandPoint0Y.ToString());
    break;
    }
    }
    }

    #2
    Hello kaywai,

    You either need to use X number of unique Tags so that they eventually start to be reused, if a tag is reused the old object is updated which would limit the number of objects to the number of tags.
    If that is not an option you need to use RemoveDrawObject to remove objects, adding them to the list is only for your convenience and does nothing for removing the objects.


    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    639 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    572 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X