NexusFi: Find Your Edge


Home Menu

 





Arraylist in Ninjatrader


Discussion in NinjaTrader

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




 
Search this Thread

Arraylist in Ninjatrader

  #1 (permalink)
no111
NED
 
Posts: 34 since May 2010
Thanks Given: 7
Thanks Received: 8

Dear all,

I've got the following problem. I have a strategy which I can test on a basket of stocks, now I want to have one equity curve therefore I want to add multiple symbols into one strategy.

I've added the symbols (SPY, DIA, SLV)and then want to work with a loop.

 
Code
                            
for (int x 0;   x++) { 

if (
Closes[x][0] > Closes[x][0
) { 
variablex Closes[x][0] } 
When using this, the different symbols will overwrite variablex. So I want to create for each symbol their own variablex.

I understand that this can be done with Arraylist.

So I add this in Variables region.
private ArrayList myArray = new ArrayList();

But how to progress further? Something like this instead of variablex?:
myArray.Add((double)(Closes[x][0]));
But then they will still write eachother over.. right?

Thanks in advance!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



no111 View Post
Dear all,

I've got the following problem. I have a strategy which I can test on a basket of stocks, now I want to have one equity curve therefore I want to add multiple symbols into one strategy.

I've added the symbols (SPY, DIA, SLV)and then want to work with a loop.

 
Code
                            
for (int x 0;   x++) { 
if (
Closes[x][0] > Closes[x][0
) { 
variablex Closes[x][0] } 
When using this, the different symbols will overwrite variablex. So I want to create for each symbol their own variablex.

I understand that this can be done with Arraylist.

So I add this in Variables region.
private ArrayList myArray = new ArrayList();

But how to progress further? Something like this instead of variablex?:
myArray.Add((double)(Closes[x][0]));
But then they will still write eachother over.. right?

Thanks in advance!

If I understand correctly, you will only have a limited know number of values for x. In that case a fixed array is more appropriate then an array list of variable dimension.

 
Code
private double[]  variablex = new double [3];


should do the trick. You can then use it as

 
Code
variablex[0] = Closes[0][0];
variablex[1] = Closes[1][0];


etc.

Reply With Quote
Thanked by:




Last Updated on July 16, 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