NexusFi: Find Your Edge


Home Menu

 





Setting multiple dataseries using a for loop


Discussion in NinjaTrader

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




 
Search this Thread

Setting multiple dataseries using a for loop

  #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?
Better Renko Gaps
The Elite Circle
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Futures True Range Report
The Elite Circle
Exit Strategy
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
65 thanks
Funded Trader platforms
41 thanks
Battlestations: Show us your trading desks!
29 thanks
NexusFi site changelog and issues/problem reporting
23 thanks
The Program
19 thanks

  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts