Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
GetAccountValue()
Collapse
X
-
Hello cassb,
GetAccountValue() has been replaced with Account.Get(AccountItem, Currency). This method does work historically, however, historical trades do not affect the account balance.
Below is a link to the help guide on Account.Get().
http://ninjatrader.com/support/helpG.../en-us/get.htmChelsea B.NinjaTrader Customer Service
-
Thank you, Chelsea, that is good news. I am getting ready to begin converting my NT7 strategies to NT8. Is there a best practices or user guide document on how to do this?Originally posted by NinjaTrader_ChelseaB View PostHello cassb,
GetAccountValue() has been replaced with Account.Get(AccountItem, Currency). This method does work historically, however, historical trades do not affect the account balance.
Below is a link to the help guide on Account.Get().
http://ninjatrader.com/support/helpG.../en-us/get.htm
Thanks!
Bryan
Comment
-
Hi cassb,
While there isn't a guide for converting, there is the code breaking changes which list the items that have changed from nt7 to nt8.
http://ninjatrader.com/support/helpG...ng_changes.htm
Also, the educational resources may be helpful.
http://ninjatrader.com/support/helpG..._resources.htmChelsea B.NinjaTrader Customer Service
Comment
-
Hi again, I hope it's OK to reuse this thread for other NT7 -> NT8 conversion questions.
I'm sorry, but I am not a C# expert, so excuse my ignorance. I see in your sample strategies that you now use the property declaration of a variable as the actual variable you define and use:
Is this just a coding style, or has something changed to require this in NT8? The NT7 version of this code is:Code:protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDescriptionSampleMACrossOver; Name = NinjaTrader.Custom.Resource.NinjaScriptStrategyNameSampleMACrossOver; Fast = 10; Slow = 25; // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = false; } [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "Fast", GroupName = "NinjaScriptStrategyParameters", Order = 0)] public int Fast { get; set; } [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "Slow", GroupName = "NinjaScriptStrategyParameters", Order = 1)] public int Slow { get; set; }
Code:#region Variables private int fast = 10; private int slow = 25; #endregion [Description("Period for fast MA")] [GridCategory("Parameters")] public int Fast { get { return fast; } set { fast = Math.Max(1, value); } } [Description("Period for slow MA")] [GridCategory("Parameters")] public int Slow { get { return slow; } set { slow = Math.Max(1, value); } }
If the NT8 version of this code is required now, I have a lot of editing to do because I have a lot of properties. Or can I just keep the NT7 style of variable definition and compile it as-is in NT8?
Thanks!
Bryan
Comment
-
Hi cassb,
This is a coding style change that is now possible with NT8. A private variable is no longer required and the public variable gets and sets itself. The older style of NT7 still works fine in NT8 where the private variable is returned and set.
Sometimes you may find a need to use the NT7 way in NT8 and use a private variable.
As an example when re-using brushes its necessary to use a private variable.
http://ninjatrader.com/support/forum...249#post461249Chelsea B.NinjaTrader Customer Service
Comment
-
Another NT8 question. In the SampleATMStrategy, there is this code in OnStateChange():
What are the variables Description and Name, and where are they defined? I tried the same code in my strategy, but I get a compile error:Code:if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDescriptionSampleATMStrategy; Name = NinjaTrader.Custom.Resource.NinjaScriptStrategyNameSampleATMStrategy; // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = false; }
'NinjaTrader.Custom.Resource' does not contain a definition for 'NinjaScriptStrategyDescriptionMyCustomStrategy'
Comment
-
I have another conversion question. This code gets the time of day from the chart:
But there is no Cbi.Globals any more. Has the MinDate.AddSeconds() function moved to a different hierarchy?Code:// Returns the 'chart' time when called. private DateTime Now { get { DateTime now = (Bars.IsInReplayMode ? NinjaTrader.Cbi.Connection.PlaybackConnection.Now: NinjaTrader.Core.Globals.Now); if (now.Millisecond > 0) now = Cbi.Globals.MinDate.AddSeconds((long) System.Math.Floor(now.Subtract(Cbi.Globals.MinDate).TotalSeconds)); return now; } }
Thanks!
Bryan
Comment
-
Hello cassb,
Thank you for your note.
The Name is the name of the script as this appears in the Indicator or Strategy window.
The Description is the description you will see on the lower left of the window when the Indicator or Strategy is selected from the list.
The Description and Name are not required to be set, but you should set these.
The SampleAtmStrategy and all of the other default NinjaTrader scripts use a resource dictionary so that the names, descriptions, labels, etc.. can be translated into other languages. This is what is being set with 'NinjaTrader.Custom.Resource.NinjaScriptStrategyDe scriptionSampleATMStrategy;'.
You don't have to do that in your script.
For an understanding of a basic setup of a NinjaScript Strategy, I would recommend you make a script with the wizard (add a few inputs) and take a look at the code that is automatically generated.
For replay time in NT8:
Cbi.Connection.PlaybackConnection.Now
For current time in NT8:
NinjaTrader.Core.Globals.NowChelsea B.NinjaTrader Customer Service
Comment
-
Did I find a bug in NT8? I am running Market Replay with my strategy, and I have a line of code that checks Bars.IsInReplayMode, and it's false. It's that line of code in my previous note:
DateTime now = (Bars.IsInReplayMode ? NinjaTrader.Cbi.Connection.PlaybackConnection.Now: NinjaTrader.Core.Globals.Now);
Shouldn't it be true when I am running Market Replay?
Bryan
Comment
-
Hi Bryan,
I've not seen that Bars.IsReplayMode and I'm not sure how it works.
However, if you want to know if replay is being played back use: Bars.IsTickReplay.
http://ninjatrader.com/support/helpG...tickreplay.htmChelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHi Bryan,
I've not seen that Bars.IsReplayMode and I'm not sure how it works.
However, if you want to know if replay is being played back use: Bars.IsTickReplay.
http://ninjatrader.com/support/helpG...tickreplay.htm
Thank you, but Bars.IsTickReplay returns False also, when running Playback mode. Is there's a function or method or property I can use to tell when my strategy is running in Playback versus Realtime?
Thanks!
Comment
-
Hi Bryan,
Thanks for your patience with this.
I gave this a quick test and realized I was also confused about this.
The Bars.IsTickReplay is letting you know whether or not tick replay is enabled.
For identifying the playback connection this can be done with the OnConnectionStatusUpdate() method.
http://ninjatrader.com/support/helpG...atusupdate.htm
Code:protected override void OnConnectionStatusUpdate(ConnectionStatusEventArgs connectionStatusUpdate) { connectionName = connectionStatusUpdate.Connection.Options.Name; Print("connectionStatusUpdate: " + connectionStatusUpdate.Connection.Options.Name); if (connectionStatusUpdate.Connection.Options.Name == "Playback Connection") { Print("Is Playback Connection"); } }Last edited by NinjaTrader_ChelseaB; 05-31-2016, 03:15 PM.Chelsea B.NinjaTrader Customer Service
Comment
-
OK thank you, that works! :-) This is a design change from NT7, because Bars.IsInReplayMode in NT7 would return True if you were running in Market Replay. Apparently that is no longer true.Originally posted by NinjaTrader_ChelseaB View PostHi Bryan,
Thanks for your patience with this.
I gave this a quick test and realized I was also confused about this.
The Bars.IsTickReplay is letting you know whether or not tick replay is enabled.
For identifying the playback connection this can be done with the OnConnectionStatusUpdate() method.
Code:protected override void OnConnectionStatusUpdate(ConnectionStatusEventArgs connectionStatusUpdate) { connectionName = connectionStatusUpdate.Connection.Options.Name; Print("connectionStatusUpdate: " + connectionStatusUpdate.Connection.Options.Name); if (connectionStatusUpdate.Connection.Options.Name == "Playback Connection") { Print("Is Playback Connection"); } }
Bryan
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
650 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
577 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment