Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Converting List to Series

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

    Converting List to Series

    Hi there,

    I am using C# Lists to track things which don't occur on every bar (e.g. ZigZag Highs). Is there a way to use existing indicators on my list values (e.g. convert the list to a series)?

    An example of what I am trying to achieve is:

    private List<double> ZigZagSwingHighs;
    ....
    else if (State == State.Configure)
    {
    ZigZagSwingHighs = new List<double>();
    }

    protected override void OnBarUpdate()
    {
    if(IsNewSwingHigh())
    ZigZagSwingHighs.Insert(0, ZigZagHigh) //The insert here replicates the series behaviour with [0] holding the latest value.

    Plot[0] = SMA(ZigZagSwingHighs, 5); // This will fail as it's a list, not a series...
    }

    #2
    Hello Adfra,

    Thank you for your post.

    You could loop through the List and add the values to a data series and then add that to the Plot.

    For example:
    Code:
    		private List<double> ZigZagHighs;
    		private Series<double> MySeries;
    
    			else if (State == State.Configure)
    			{
    				ZigZagHighs = new List<double>();
    				MySeries	= new Series<double>(this);
    			}
    
    			if (IsNewSwingHigh())
    				ZigZagSwingHighs.Insert(0, ZigZagHigh);
    			
    			for (int i = ZigZagHighs.Count; i >= 0; i--)
    			{
    				MySeries[i] = ZigZagHighs[i];
    			}

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    152 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    87 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    131 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    127 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    106 views
    0 likes
    Last Post CarlTrading  
    Working...
    X