How do you create a List to store variables? - NinjaTrader Programming | futures io social day trading
futures io futures trading


How do you create a List to store variables?
Updated: Views / Replies:5,777 / 15
Created: by forrestang Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 2  
 
Thread Tools Search this Thread
 

How do you create a List to store variables?

  #11 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received

I got done what I wanted. Initially I was wanting to create a List so that I could print things out in a specific order via Print() command for later use in excel.

But I figured out how to set up a DDE with NT and excel, so I am able to directly populate a spreadsheet the way I want.

Thanks.

Reply With Quote
 
  #12 (permalink)
Elite Member
Chicago IL
 
Futures Experience: Beginner
Platform: Sierra Chart
Favorite Futures: Futures
 
Posts: 117 since Feb 2012
Thanks: 22 given, 110 received


gomi View Post
You can access a List<T> by index.

List<double> will have a better performance than ArrayList because doubles won't be casted to objects when inserting, and objects won't be casted to doubles when accessing. List<double> will also be safer because you will always be sure your list only contains valid doubles, not random objects.

So IMO you'd better use List<double>. ArrayLists are legacy objects used before generic collections appeared in .NET 2.0

Usage is easy, here is an example I found on C# List Examples

 
Code
    
List<int> list = new List<int>();

list.Add(2);     
list.Add(3);     
list.Add(7);     

foreach (int prime in list) // Loop through List with foreach     
{         
Console.WriteLine(prime);     
}

Oops you are definitely right. Momentary brainfart there.

Reply With Quote
 
  #13 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received



Fat Tails View Post
You can use an ArrayList object. It is basically an array with a variable size, which allows you to add elements of various data types.

Step 1: create the array list:

 
Code
private ArrayList  myArray = new ArrayList();
You have now an empty ArrayList.


Step 2: Add elements to your array list:

 
Code
myArray.Add((double)(Input[0]));
It is important to specify the data type that you add.


Step 3: Retrieve the stored value.

 
Code
value =  (double) myArray[5];
This will retrieve the 6th value that you have added.

Tip
When adding or retrieving a value, you need to specify the data type which is stored in the array list. Without adding (double) in front of the array element, neither adding nor retrieving a value will work.


Of course you can use other data types, for example you can add (string) values.


Further information on array lists is here:

ArrayList Class (System.Collections)

C# ArrayList Tips

I'm working off this one as it is the simplest presented in this thread. But it doesn't seem to work in NT? I get this error.

Attached Thumbnails
How do you create a List to store variables?-2012-03-27_131122.png  
Reply With Quote
 
  #14 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received

Basically the structure would be like the attached picture, where as certain conditions occur or are met, I can just throw the value in whatever index the next empty slot is.

Then be able to access the values later, or reset the container.

Attached Thumbnails
How do you create a List to store variables?-3-27-2012-1-42-34-pm.png  
Reply With Quote
 
  #15 (permalink)
Elite Member
Atkinson, NH USA
 
Futures Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker/Data: NinjaTrader Brokerage
Favorite Futures: Futures, CL, ES, ZB
 
NJAMC's Avatar
 
Posts: 1,925 since Dec 2010
Thanks: 2,962 given, 2,294 received


forrestang View Post
I'm working off this one as it is the simplest presented in this thread. But it doesn't seem to work in NT? I get this error.

You probably need to add something like this to the top of the code (in the declarations section):

 
Code
using System.Collections

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Reply With Quote
The following 3 users say Thank You to NJAMC for this post:
 
  #16 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received


NJAMC View Post
You probably need to add something like this to the top of the code (in the declarations section):

 
Code
using System.Collections

Oh wow, thanks, at least it compiles now! I'm so bad at writing ninjaScripts.

Will try it again in a bit.

Reply With Quote

Reply



futures io > > > > > How do you create a List to store variables?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for Software to store Price data in MySQL caliph Matlab, R project and Python 4 January 7th, 2013 03:11 PM
Store real time data from NT in mysql bascher NinjaTrader 23 November 4th, 2011 06:53 AM
Exposing variables kaywai NinjaTrader Programming 4 April 14th, 2011 12:58 PM
How can I store the first order limit price as a variable to use for calculating... richw NinjaTrader Programming 2 February 22nd, 2011 03:58 PM
PLT_NTDataCollect store bid ask tick data to its local database? rcabri Trading Reviews and Vendors 3 December 27th, 2010 11:00 AM


All times are GMT -4. The time now is 10:52 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.10 seconds with 20 queries on phoenix via your IP 54.145.16.43