NexusFi: Find Your Edge


Home Menu

 





Using Account Object in NinjaTrader


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one maxi with 8 posts (0 thanks)
    2. looks_two MWinfrey with 7 posts (1 thanks)
    3. looks_3 vvhg with 6 posts (3 thanks)
    4. looks_4 terratec with 5 posts (1 thanks)
    1. trending_up 10,858 views
    2. thumb_up 5 thanks given
    3. group 6 followers
    1. forum 26 posts
    2. attach_file 0 attachments




 
Search this Thread

Using Account Object in NinjaTrader

  #11 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
Posts: 403 since Sep 2009
Thanks Given: 64
Thanks Received: 515

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.

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #12 (permalink)
maxi
Rome, Italy
 
Posts: 17 since Jul 2010
Thanks Given: 2
Thanks Received: 1

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)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
Posts: 403 since Sep 2009
Thanks Given: 64
Thanks Received: 515



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)
maxi
Rome, Italy
 
Posts: 17 since Jul 2010
Thanks Given: 2
Thanks Received: 1

Well, is quite warm in Italy at mom.

Enjoy your bike tour

Reply With Quote
  #15 (permalink)
 
MWinfrey's Avatar
 MWinfrey 
Lubbock TX
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Stage 5 Trading
Trading: CL
Posts: 1,878 since Jul 2009
Thanks Given: 1,450
Thanks Received: 3,335

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)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,583 since Mar 2011
Thanks Given: 1,016
Thanks Received: 2,824


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
Thanked by:
  #17 (permalink)
 
MWinfrey's Avatar
 MWinfrey 
Lubbock TX
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Stage 5 Trading
Trading: CL
Posts: 1,878 since Jul 2009
Thanks Given: 1,450
Thanks Received: 3,335


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)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,583 since Mar 2011
Thanks Given: 1,016
Thanks Received: 2,824


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)
 
MWinfrey's Avatar
 MWinfrey 
Lubbock TX
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Stage 5 Trading
Trading: CL
Posts: 1,878 since Jul 2009
Thanks Given: 1,450
Thanks Received: 3,335


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)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,583 since Mar 2011
Thanks Given: 1,016
Thanks Received: 2,824



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




Last Updated on November 20, 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