NexusFi: Find Your Edge


Home Menu

 





Setting multiple dataseries using a for loop


Discussion in NinjaTrader

Updated
    1. trending_up 1,875 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,377

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?
SEC Advisory Committee Backs Tokenized Securities Exempt …
Traders Hideout
The Week Ahead -- CPI Wednesday With Oil Past $90, PPI L …
Traders Hideout
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
UCL Final Kicks Off at Noon ET: PSG at 56.5% as Iran May …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 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,377

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