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:-
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; } } }
Comment