I'm trying to print the values from an ArrayList - NinjaTrader Programming | futures io social day trading
futures io futures trading


I'm trying to print the values from an ArrayList
Updated: Views / Replies:2,692 / 13
Created: by kaywai Attachments:1

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
 1  
 
Thread Tools Search this Thread
 

I'm trying to print the values from an ArrayList

  #1 (permalink)
Trading for Fun
singapore
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: IB
Favorite Futures: ES, forex, oil
 
Posts: 131 since Nov 2009
Thanks: 11 given, 7 received

I'm trying to print the values from an ArrayList

This is part of the debugging process. Could someone please tell me how I can do that?

Regards

Kay Wai

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received



kaywai View Post
This is part of the debugging process. Could someone please tell me how I can do that?

Regards

Kay Wai

 
Code
   public static void PrintValues( IEnumerable myList )  {
      foreach ( Object obj in myList )
         Console.Write( "   {0}", obj );
      Console.WriteLine();
   }
谷歌是我們的朋友

Math. A gateway drug to reality.
Reply With Quote
 
  #4 (permalink)
Trading for Fun
singapore
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: IB
Favorite Futures: ES, forex, oil
 
Posts: 131 since Nov 2009
Thanks: 11 given, 7 received

Will try it. Thx!

Reply With Quote
 
  #5 (permalink)
Trading for Fun
singapore
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: IB
Favorite Futures: ES, forex, oil
 
Posts: 131 since Nov 2009
Thanks: 11 given, 7 received

I'm probably doing something wrong here. I can't seem to Add and Remove values from the ArrayList. The prints are not going to the output window. Could someone please help? I've attached the code. TIA! Kay Wai

P/S It's the first file in the zipfile.

Attached Files
Register to download File Type: zip ky.zip (7.3 KB, 17 views)

Last edited by kaywai; May 12th, 2011 at 04:47 AM.
Reply With Quote
 
  #6 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: NinjaTrader Brokerage
Favorite Futures: ES
 
NinjaTrader's Avatar
 
Posts: 1,260 since May 2010
Thanks: 153 given, 1,890 received


kaywai View Post
I'm probably doing something wrong here. I can't seem to Add and Remove values from the ArrayList. The prints are not going to the output window. Could someone please help? I've attached the code. TIA! Kay Wai

P/S It's the first file in the zipfile.


Your problem is that your .Add() call will never be reached since you have a check in place on the list.Count property being greater than 2.

Reply With Quote
 
  #7 (permalink)
Trading for Fun
singapore
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: IB
Favorite Futures: ES, forex, oil
 
Posts: 131 since Nov 2009
Thanks: 11 given, 7 received

May I know why that is the case? I only want to store the 2 most recent observations and discard the older observations.

Perhaps you could suggest a better way of doing this.

These observations only come about when a bool is true and I want to use the 2 most recent observations to draw horizontal lines which updates as new bars are created and stops when either 1) another bool becomes true or 2) the observation is "old". However, I would like to keep the old line on the chart, if possible.

I thought about using the DataSeries but I understand that when there is "no" data for it to add, it defaults to zero. trying to avoid that problem.

Reply With Quote
 
  #8 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: NinjaTrader Brokerage
Favorite Futures: ES
 
NinjaTrader's Avatar
 
Posts: 1,260 since May 2010
Thanks: 153 given, 1,890 received


kaywai View Post
May I know why that is the case? I only want to store the 2 most recent observations and discard the older observations.

Perhaps you could suggest a better way of doing this.

These observations only come about when a bool is true and I want to use the 2 most recent observations to draw horizontal lines which updates as new bars are created and stops when either 1) another bool becomes true or 2) the observation is "old". However, I would like to keep the old line on the chart, if possible.

I thought about using the DataSeries but I understand that when there is "no" data for it to add, it defaults to zero. trying to avoid that problem.

Sure, you have a logic flaw in your code. Your code says only add to the arraylist if the arraylist has more than 2 items in it. Since the arraylist starts with a count of zero, it will never be greater than 2 since it can only ever be added to once the count is greater than 2. In other words, the greater than 2 condition can never be true.

This condition will never be executed since .Count > 2 will never be true. Your need to move the .Add() call outside of this if branch.

 
Code
if (TDSTBuy.Count > 2)
{ 
   TDSTBuy.RemoveAt(0); //if TDSTBuy is filled, drop the oldest value
   TDSTBuy.Add(setuphigh);
   Print(Time[0]);
 
}


Reply With Quote
The following user says Thank You to NinjaTrader for this post:
 
  #9 (permalink)
Trading for Fun
singapore
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: IB
Favorite Futures: ES, forex, oil
 
Posts: 131 since Nov 2009
Thanks: 11 given, 7 received

HAHAHAHA! Thx much!

Reply With Quote
 
  #10 (permalink)
Trading for Fun
singapore
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: IB
Favorite Futures: ES, forex, oil
 
Posts: 131 since Nov 2009
Thanks: 11 given, 7 received


I change it like below, and I still don't know whether I'm getting anything into the ArrayList. Would you mind please helping?

 
Code

if (TDBuyExtendedSetupFX().buysetupmoveiscompleted)
{

drawtdstbuyline = true;
setuphigh = TDBuyExtendedSetupFX().hhbs;
TDSTBuy.Add(setuphigh);
if (TDSTBuy.Count > 2)
{
TDSTBuy.RemoveAt(0); //if TDSTBuy is filled, drop the oldest value
}
Console.WriteLine( "TDSTBuy" );
Console.WriteLine( " Count: {0}", TDSTBuy.Count );
Console.WriteLine( " Capacity: {0}", TDSTBuy.Capacity );
Console.Write( " Values:");
PrintValues(TDSTBuy);
}
}
publicstaticvoid PrintValues( IEnumerable TDSTBuy)
{
foreach (Object obj in TDSTBuy ) 
Console.Write(" {0}", obj);
Console.WriteLine();
}

Reply With Quote

Reply



futures io > > > > > I'm trying to print the values from an ArrayList

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to extract nearest support price from arraylist? zacharydw00 NinjaTrader Programming 15 January 1st, 2012 02:57 AM
Anyone using Print+ from moneyflowbars.com? Need your help Chipmunk Trading Reviews and Vendors 5 October 20th, 2010 05:30 AM
Print format for Forex variables arjfca EasyLanguage Programming 2 October 3rd, 2010 10:57 AM
Redirect Print output to my logger dimkdimk NinjaTrader Programming 1 January 14th, 2010 05:43 AM
Translating EMA-values to ZN-values or visaversa max-td NinjaTrader Programming 17 June 22nd, 2009 04:42 PM


All times are GMT -4. The time now is 04:18 AM.

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-17 in 0.14 seconds with 20 queries on phoenix via your IP 54.227.51.103