GetAccountValue in an Indicator - NinjaTrader Programming | futures io social day trading
futures io futures trading


GetAccountValue in an Indicator
Updated: Views / Replies:3,810 / 14
Created: by Mindset 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
 

GetAccountValue in an Indicator

  #1 (permalink)
Elite Member
UK
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: ib
Favorite Futures: Electric Guitar
 
Mindset's Avatar
 
Posts: 355 since Sep 2009
Thanks: 88 given, 285 received

GetAccountValue in an Indicator

Can anyone provide a code snippet to get the value of a specified account in an Indicator.
It's a doddle in a strategy but I require it in an indicator and can't seem to get it

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)
Elite Member
Wrocław, Poland
 
Futures Experience: Intermediate
Platform: NinjaTrader, Racket
Favorite Futures: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 321 given, 605 received


Have you tried adding following declaration to your indicator code:

using NinjaTrader.Cbi;
using NinjaTrader.Strategy;

Reply With Quote
 
  #4 (permalink)
Elite Member
UK
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: ib
Favorite Futures: Electric Guitar
 
Mindset's Avatar
 
Posts: 355 since Sep 2009
Thanks: 88 given, 285 received

Get Account value

Thanks Gregid - tried that - makes no difference seemingly.

Reply With Quote
 
  #5 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received


Mindset View Post
Can anyone provide a code snippet to get the value of a specified account in an Indicator.
It's a doddle in a strategy but I require it in an indicator and can't seem to get it

I recall that question on the NT Forums being answered by support staff as 'the info wasnt available to indicators' ... I made a request that it should ... I have yet to see any of my requests showup in NT

Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
 
  #6 (permalink)
Elite Member
UK
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: ib
Favorite Futures: Electric Guitar
 
Mindset's Avatar
 
Posts: 355 since Sep 2009
Thanks: 88 given, 285 received

Indeed

Displaying account equity and margin in Market Analyzer - NinjaTrader Support Forum

They must have an awfully long list of stuff to add to NT - it's rare to get anything actually done about these requests.
Just think a trading platform where you can't get access to your account balances in an indicator.....must have taken some designing that.

Reply With Quote
 
  #7 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Don't know if it helps but I run a custom method in a risk management strat that looks at global PnL (and a bunch of other things). Here is the method code. The variables should be pretty easy to figure out. If not I can point you to the full strat over in the Elite section.

 
Code
                            
#region AccountMonitor()
private void AccountMonitor()
// Custom method to monitor the cash account balance. This should be considered as a LAST line of defense and not a suggested way to monitor session P&L.
// Note this is tied to the 5 min bar series.
{//Open AccountMonitor()
 
buyingpower GetAccountValue(AccountItem.BuyingPower);
realPnL GetAccountValue(AccountItem.RealizedProfitLoss);
cashValue GetAccountValue(AccountItem.CashValue);
 
switch(
acctType)
{
case(
AccountType.CashValue):
{
currentAccountValue GetAccountValue(AccountItem.CashValue);
break;
}
case(
AccountType.BuyingPower):
{
currentAccountValue GetAccountValue(AccountItem.BuyingPower);
break;
}
}
if (
BarsInProgress == && FirstTickOfBar && printCurrentAccountValue)
{
Print(
DateTime.Now " " Account.Name " Current Account Value: $" Math.Round(currentAccountValue2));
 
/*
//You can use this code block to see what type of account information your provider supports
Print(Account.Name + " Buying Power: $" + buyingpower);
Print(Account.Name + " Realized P&L: $" + realPnL);
Print(Account.Name + " Cash Value: $" + cashValue);
*/
}
 
if (
BarsInProgress == && applyAccountMonitor && currentAccountValue == 0)
{
Print(
DateTime.Now " ERROR: AccountMonitor() returns 0 for CurrentAccountValue");
if (
alertsWindowAlert("accountzero"NinjaTrader.Cbi.Priority.Medium"CurrentAccountValue = 0""Alert1"10Color.YellowColor.White);
}
 
if (
BarsInProgress == && applyAccountMonitor && FirstTickOfBar)
{
 
if (
currentAccountValue <= openingAccountValue -((maxAccountLoss/100)*openingAccountValue))// Note this is tied to the 5 min bar series
{
Print(
"");
Print(
"!!!!FLATTEN EVERYTHING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Print(
DateTime.Now " SYSTEM MONITOR: Global Loss Limit Exceeded!");
Print(
"Opening Account value: $" openingAccountValue);
Print(
"Current Account Value: $" currentAccountValue); 
if (
alertsWindowAlert("globalloss"NinjaTrader.Cbi.Priority.High"Global Loss Limit Exceeded""triple_klaxon.wav"10Color.RedColor.White);
if (
logAlertsLog("SystemMonitor: Global Loss Limit Exceeded"NinjaTrader.Cbi.LogLevel.Error);
Print(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Print(
"");
GetFlat();
}
}
}
//Close Account Monitor
#endregion 

Reply With Quote
The following user says Thank You to MXASJ for this post:
 
  #8 (permalink)
Elite Member
UK
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: ib
Favorite Futures: Electric Guitar
 
Mindset's Avatar
 
Posts: 355 since Sep 2009
Thanks: 88 given, 285 received

Strat

MXASJ - thanks, but you still run into the issue that GetAccountValue() simply doesn't exist in an indicator - only in a strategy for some bizarre reason.

Reply With Quote
 
  #9 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received


Mindset View Post
MXASJ - thanks, but you still run into the issue that GetAccountValue() simply doesn't exist in an indicator - only in a strategy for some bizarre reason.

Yep. Global PnL is my workaround. There are some other "Utility" methods in Ninja that don't work in both Strats and Indis. PrintWithTimeStamp(), for example, only works in Strats IIRC.

Reply With Quote
 
  #10 (permalink)
Elite Member
Huntsville AL/USA
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Stocks, Futures
 
d1g1talfr3ak's Avatar
 
Posts: 24 since Nov 2011
Thanks: 31 given, 46 received

Update indicator with info from strategy



Mindset View Post
MXASJ - thanks, but you still run into the issue that GetAccountValue() simply doesn't exist in an indicator - only in a strategy for some bizarre reason.

I have several indicators that have needed info only available in the strategy... I just have the strat pass the info to the indicator.

This code is in my EquityCurve Indicator

 
Code
		public void setEC(double val)
		{
			this.ec = val;
			this.Update();
		}
		
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            PlotEC.Set(ec);
        }
And then in the strategy, in the OnBarUpdate:

 
Code
			ecInd.setEC(Performance.AllTrades.TradesPerformance.Currency.CumProfit);

Reply With Quote

Reply



futures io > > > > > GetAccountValue in an Indicator

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
     


All times are GMT -4. The time now is 01:37 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-16 in 0.12 seconds with 18 queries on phoenix via your IP 23.22.136.56