A common pitfall with NinjaTrader 7 strategies is the
default parameters are defined on a per strategy basis.
This means that each strategy can have only one
default parameter set. Using several strategies and
several instruments the user is often forced to re-
input the parameters at each program start. This
procedure is prone to errors and also very time
consuming. In cas of a crash all your parameters might
As an enhancement to the NinaTrader logic I came up
with the following solution:
1. Parameters are saved relative to the instrument and
to an external .xml file, for example
Whenever you load a new strategy the parameters
contained in the .xml file are loaded.
2. Instrument Lists are supported:
When you load an Instrument List into a strategy each
single strategy will load parameters from its .xml
1. Add reference to
2. Derive your class from
4. Define a function public override void
Deserialize() and define the parameters to
use from the loaded parameterset.
5. Optional: define a function AccountContraints
for special handling (for example Day order
versus GTC orders)
6. Call SaveParams() where convenient for you
7. (if you dont’like the deriving from
code for StrategyWithPersitentParameters is
supplied and you can incorporate also directy
in your strategies.
My interest is an automatic Email or SMS
utility. So I defined the email address and
SMS mobile number as global variables. I
defined also 2 bool flags, bEmail and bSms.
These 2 flags define whether the Email or
Sms option is active. Since I use the
StrategyPersistenceHandler.dll plugin I the
parameters are persistent.
You have 2 functions only: saveGlobals and
As additional convenience you can edit the
globals directly from the new strategy dialog
and the globals are just the parameters of the
source code of GlobalSettings is available on
Example of integration with
Defining and recalling Global
Session parameters from any
place in your code.
Per instrument Strategy persistence for NinjaTrader 7
Start strategy1 on
(contains ES 09-11 and NQ
=> Strategy1 ES 09-11
=> Strategy1 NQ 09-11
3. This addon can be integrated in all strategies where you
have source code.
4. The advantages are:
->high protection of your parameters sets (the .xml file does
survive NT crashes)
->less clutter in the ControlCenter Strategy Tab Window.
Only active strategies must be present and
strategies can be safely removed.
-->What you see is what you get: All parameters actually
loaded are visible in the New Strategy Dialog and you can be
sure that these are actually loaded. (This is not the case
with most home-made solutions for strategy persistence.
->Remember: You are moving real money with your
strategies and usually one single typo in the parameters will
cost you more than a full license.
->Easily port parameters from one computer to another
computer (by copying the .xml files)