NexusFi: Find Your Edge


Home Menu

 





Setting multiple dataseries using a for loop


Discussion in NinjaTrader

Updated
    1. trending_up 1,958 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,378

I was wondering if it is possible to set a large amount of dataseries using a for loop. For example, say I have 64 dataseries named myDataSeries0, myDataSeries1,....myDataSeries63. Is it possible to pass i into into a structure to set all of these in the same loop?

Something similar to this, but that works

for(int i=0;i<64;i++)
{
myDataSeries+i.Set(myArray[i]);
}


Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
Warsh Confirmed 54-45 on PPI Day -- 97% Say He Holds in …
Prediction Markets & Event Contracts
Wood Mackenzie Drops $200 Oil Forecast -- Airspace Expir …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
10 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 649 since Aug 2009
Thanks Given: 320
Thanks Received: 623


You can use Dictionary for that:

 
Code
                            
private Dictionary<intDataSeriesd//in Variables section
= new Dictionary<intDataSeries>();    //in initialize
for (int i 0dsCounti++) //wherever
{
    
d[i] = new DataSeries(this);
}

//to set the values
for (int i 0dsCounti++)
{
    
d[i][0] = 343453.44 //setting data series d[i] value for current bar
}
//to access the values
for (int i 0dsCounti++)
{
    Print(
"Value of the data series: "d[i][0]); //getting data series d[i] value for current bar


Reply With Quote
Thanked by:
  #4 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,378

Thanks @gregid. I will try it when I get home. This should take 2000+ lines of code and trim it down to 400-500


Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on August 28, 2012


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts