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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    560 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    325 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X