Using Account Object in NinjaTrader - NinjaTrader Programming | futures io social day trading
futures io futures trading


Using Account Object in NinjaTrader
Updated: Views / Replies:4,871 / 26
Created: by maxi Attachments:0

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

Using Account Object in NinjaTrader

  #11 (permalink)
Elite Member
Zurich Switzerland
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IB
Favorite Futures: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 511 received

I never had a problem with partial fill. So I did not code it

Maybe you could try something with a.Position.Count
(But.... a.Positions.Count is difficult because it is not instrument but account specific!! So this alone is not enough.)
Or compare a variable with position before and after execution and order size.

But i don't know. That is a reason for my switch to strategies, as all that stuff is very easy there and does not take hours to find out.


Last edited by terratec; July 6th, 2012 at 05:42 PM.
Reply With Quote
The following user says Thank You to terratec for this post:
 
  #12 (permalink)
Trading Apprentice
Rome, Italy
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Equity Index Futures
 
Posts: 17 since Jul 2010
Thanks: 2 given, 0 received

Yes, I agree with you.

Strategies are easier for managing orders (I've coded several..) but my project at the moment is addressed to discretionary trading, so I'd need ChartTrader and something that could be tailored on it (different from ATM of course..!).

Thanks.

Nice we.

Reply With Quote
 
  #13 (permalink)
Elite Member
Zurich Switzerland
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IB
Favorite Futures: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 511 received



maxi View Post
...but my project at the moment is addressed to discretionary trading, so I'd need ChartTrader and something that could be tailored on it

I am trading discretionary. At the end of the day it was easier for me to create the missing parts of a strategy chart, like ChartTrader tools, plot visualization of positions, stops, targets etc. than doing the trade and account stuff in indicators. By the way, a combination of indicator/strategy is a solution too, that I often use.

Have a nice WE too. I will be soon in Italy (Tuscany) for some days with my bici.

Reply With Quote
 
  #14 (permalink)
Trading Apprentice
Rome, Italy
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Equity Index Futures
 
Posts: 17 since Jul 2010
Thanks: 2 given, 0 received

Well, is quite warm in Italy at mom.

Enjoy your bike tour

Reply With Quote
 
  #15 (permalink)
Elite Member
Lubbock TX
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Stage 5 Trading
Favorite Futures: CL
 
MWinfrey's Avatar
 
Posts: 1,879 since Jul 2009
Thanks: 1,449 given, 3,306 received

Curious if anyone has been successful retrieving the cash value of an account. I am using Account.GetAccountValue(AccountItem.CashValue,Currency.UsDollar). I can get the name of the account but nothing else.

Reply With Quote
 
  #16 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received


MWinfrey View Post
Curious if anyone has been successful retrieving the cash value of an account. I am using Account.GetAccountValue(AccountItem.CashValue,Currency.UsDollar). I can get the name of the account but nothing else.

I think you have to get the Account object first like this:
 
Code
NinjaTrader.Cbi.Globals.Accounts[0].GetAccountValue(AccountItem.CashValue, Currency.UsDollar);

This post might be helpful in finding the right account:

maxi View Post
terratec, need more help please.

I need to insert an order and, if filled, a stop and target orders must be placed on the market.

I tried with you suggestion this way:

 
Code
 #region Variables        
		
Order b = null;
		
#endregion

protected override void OnStartUp()
        {
string accName = ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"].Text;		
			accnt = null;		
			for (int i = 0;i <= NinjaTrader.Cbi.Globals.Accounts.Count - 1; i++)
				{
					if (NinjaTrader.Cbi.Globals.Accounts[i].Name == accName)
					{
					accnt = NinjaTrader.Cbi.Globals.Accounts[i];
					}
				}

// I created a button where I linked the following to enter a buy stop order:

#region Entry
		private void btnOrdSend_Click(object s, EventArgs e)
		{
			
		int quantity = 1;
		
		if (quantity < 1 || entryprice <=1) return;			
		
		if (accnt != null)
			{
				
				b = accnt.CreateOrder(Instrument,OrderAction.Buy,OrderType.Stop,TimeInForce.Day,quantity,0,entryprice,"","Buy");
				b.Submit();	
				
			}		
		}		
		#endregion

// I'm trying to see if the order is filled with the following on OnBarUpdate

protected override void OnBarUpdate()
        {
            
           if (b.OrderState == OrderState.Filled)
			{
			MessageBox.Show("Filled");
			}
			
			
        }
The button perfectly insert the buy stop order on the market but, once filled, no message is shown.
I'm a bit confused on the way the stop/target orders should be coded.

Probably they shouldn't be inserted in the OnBarUpdate space?

I've seen the use of the override Plot, but I've never used it so I don't know how to manage it.

Thanks for any hint


vvhg

Hic Rhodos, hic salta.
Reply With Quote
The following user says Thank You to vvhg for this post:
 
  #17 (permalink)
Elite Member
Lubbock TX
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Stage 5 Trading
Favorite Futures: CL
 
MWinfrey's Avatar
 
Posts: 1,879 since Jul 2009
Thanks: 1,449 given, 3,306 received


vvhg View Post
I think you have to get the Account object first like this:
 
Code
NinjaTrader.Cbi.Globals.Accounts[0].GetAccountValue(AccountItem.CashValue, Currency.UsDollar);

This post might be helpful in finding the right account:



vvhg

Thanks...I didn't include that in my first post but that's exactly what I'm doing.

Reply With Quote
 
  #18 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received


MWinfrey View Post
Thanks...I didn't include that in my first post but that's exactly what I'm doing.

Do you get any errors?
Did you check for null?
And have you tried:
 
Code
NinjaTrader.Cbi.Globals.Accounts[0 or whatever acct you want].GetAccountValue(AccountItem.CashValue, Currency.UsDollar).Value
vvhg

Hic Rhodos, hic salta.
Reply With Quote
 
  #19 (permalink)
Elite Member
Lubbock TX
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Stage 5 Trading
Favorite Futures: CL
 
MWinfrey's Avatar
 
Posts: 1,879 since Jul 2009
Thanks: 1,449 given, 3,306 received


vvhg View Post
Do you get any errors?
Did you check for null?
And have you tried:
 
Code
NinjaTrader.Cbi.Globals.Accounts[0 or whatever acct you want].GetAccountValue(AccountItem.CashValue, Currency.UsDollar).Value
vvhg

no error in the log or output window. just added .Value and no change. following is my code...

 
Code
for (int i = 0;i <= NinjaTrader.Cbi.Globals.Accounts.Count - 1; i++)
{
	if (NinjaTrader.Cbi.Globals.Accounts[i].Name == Account.Name)
	{
		accnt = NinjaTrader.Cbi.Globals.Accounts[i];
		Print(accnt.Name + " " + 	accnt.GetAccountValue(AccountItem.CashValue,Currency.UsDollar).Value);
	}
}
the output is

RisingFallingCL 0

So as you can see the cash value reports as zero.

Reply With Quote
 
  #20 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received



MWinfrey View Post
no error in the log or output window. just added .Value and no change. following is my code...

 
Code
for (int i = 0;i <= NinjaTrader.Cbi.Globals.Accounts.Count - 1; i++)
{
	if (NinjaTrader.Cbi.Globals.Accounts[i].Name == Account.Name)
	{
		accnt = NinjaTrader.Cbi.Globals.Accounts[i];
		Print(accnt.Name + " " + 	accnt.GetAccountValue(AccountItem.CashValue,Currency.UsDollar).Value);
	}
}
the output is

RisingFallingCL 0

So as you can see the cash value reports as zero.

Yes, I get the exact same behavior, on all items...

vvhg

Hic Rhodos, hic salta.
Reply With Quote

Reply



futures io > > > > > Using Account Object in NinjaTrader

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
Error: Object reference not set to an instance of an object. gomad NinjaTrader Programming 11 December 22nd, 2014 09:09 AM
Ninjatrader sim account license that never expires calvinmr NinjaTrader 5 March 3rd, 2011 01:51 AM
need help :: cant fix :: Object reference not set to an instance of an object Trader.Jon NinjaTrader Programming 9 November 3rd, 2010 11:55 AM
Object-oriented design for complex NinjaTrader strategies shodson NinjaTrader Programming 5 June 5th, 2010 04:36 PM
NinjaTrader Account Performance Tabissues Gabe2004 NinjaTrader 1 December 2nd, 2009 08:27 AM


All times are GMT -4. The time now is 04:04 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-15 in 0.14 seconds with 19 queries on phoenix via your IP 54.90.92.204