Accessing List objects
Accessing List objects
07 Jul 2023, 10:39
Hi All,
Hopefully this is just a quick and easy one! I've created a list, and i've added some elements to it. I was hoping i'd be able to run a for loop to access each individual entry, but my output is just a single "0", followed by a further single, "1".
var highbars = MarketData.GetBars(TimeFrame.Daily, SymbolName);
var plist = new List<DataSeries>();
plist.Add(highbars.HighPrices);
for(int i=0; i<=plist.Count(); i++)
{
Print(i);
}
I wanted to output each of the values of the list. Could anyone point me in the right direction?
Thank you
Replies
Giorgi_1
07 Jul 2023, 10:54
RE:
Kaspricci said:
With plist.Add(highbars.HighPrices) you just add the whole list of high prices as one single element of your own list.
And actually you don't need a new list. HighPrices is already one. Just try this code below:
var highbars = MarketData.GetBars(TimeFrame.Daily, SymbolName); foreach(double price in highbars.HighPrices) { Print(price); }
Ah ok, i understand. I've added the list, not the elements of the list.
Thank you for clarifying :)
Do you know if there's a function or selection i can use to remove duplicates from a list?
@Giorgi_1
Best.Algo.Trader
07 Jul 2023, 10:48
With plist.Add(highbars.HighPrices) you just add the whole list of high prices as one single element of your own list.
And actually you don't need a new list. HighPrices is already one. Just try this code below:
@Best.Algo.Trader