Operations > Automated Trading > Running NinjaScript Strategies >

Running a NinjaScript Strategy from a Chart

Print this Topic Previous pageReturn to chapter overviewNext page

You can run a NinjaScript strategy in real-time in a live or simulation account within a NinjaTrader chart.


tog_minusHow to run a NinjaScript strategy in a chart

Setup Tips

Following are some key points and instructions on on how to run a NinjaScript strategy from a chart.


NinjaTrader MUST be connected to a live brokerage or market data vendor. You can also use the Market Replay or Simulated Data Feed connections as well.
Strategy menu options will NOT appear if not connected live
You can not run Chart Trader on a chart while you have a running strategy applied to the chart
On terminating (stop running) a strategy, all strategy generated trade markers or draw objects will be removed from the chart
A NinjaScript strategy is a self contained automated trading system and orders generated are live and not virtual. Cancelling strategy generated orders manually can cause your strategy to stop executing as you designed it. If you want to manually cancel an order, terminate the strategy itself.
Running and disabled strategies are also displayed in the Control Center window Strategies tab
If running an FX strategy, please review the "Running FX Strategies" section for critical information



Running a NinjaScript Strategy (see image below)

To run a NinjaScript strategy within a chart:


1.Within an open chart, either select the Strategies... menu from within the right mouse button click context menu, the Strategies icon from the tool bar or press the default CTRL + S Hot Key on your keyboard to bring up the Strategies dialog window


2.You can add/remove and set up live strategies from within the Strategies dialog window pictured to the right:


    1. List of available strategies

    2. List of applied strategies to run on the chart

    3. Selected strategy's properties


3.From the list of available strategies (section 1 in the image below) select a strategy and either press the New button or double click on the strategy


4.Once added to the list of applied strategies (section 2 in the image below), you can now edit the strategy's properties


5.Set the strategies properties (section 3 in the image below). You must set the property Enabled to True to actually turn on the strategy.


6.Press the "OK" button to run the strategy


7.To terminate (stop running) a strategy, you can highlight a running strategy and press the Remove button within the Strategy dialog window which would completely remove the strategy from the chart and Control Center's Strategies tab. Alternatively you can set the Enabled property to False to simply disable the strategy and allow you to re-enable the strategy at a later point in time without needing to reparameterize it.



tog_minusUnderstanding strategy properties

Strategy Properties

The image below shows the adjustable properties for a strategy available in the Strategies dialog window (see the "How to run a NinjaScript strategy in a chart" section above):



Parameters section

Sets any strategy specific user defined inputs


Sets the account the strategy will execute orders in

Calculate on bar close

If true, will only calculate the strategy's value on the close of a bar. If false, will calculate the strategy's value on each incoming tick.


Enables or disables the active strategy

Input series

Please see the Input series section for further information.


Sets a text label that will be displayed on the chart to represent the strategy

Maximum bars look back

Sets the maximum number of historical bars to use for strategy calculations. The TwoHundredFiftySix setting is the most memory friendly.

Min. bars required

Sets the minimum number of bars required before the backtest will start processing

Fill Type

Sets the algorithm for processing and filling orders on the historical data portion of the chart


Sets the slippage amount in ticks for the historical portion of the chart

Entries per direction

Sets the maximum number of entries allowed per direction while a position is active based on the "Entry handling" property

Entry handling

Sets the manner in how entry orders are handled. If set to "AllEntries", the strategy will process all entry orders until the maximum allowable entries set by the "Entries per direction" property has been reached while in an open position. If set to "UniqueEntries", strategy will process entry orders until the maximum allowable entries set by the "Entries per direction" property per each uniquely named entry.

Exit on close

When enabled, open positions are closed on the last bar of a session

Exit on close seconds

Sets the number of seconds prior to the end of a session when open positions of a strategy will be closed

Stop & target submission

Sets how stop and target orders are submitted

Sync account position

Enables or disables an automatic attempt to sync the account position and strategy position.

Set order quantity

Sets how the order size is determined, options are:

"by default quantity" - User defined order size

"by strategy" - Takes the order size specified programmatically within the strategy
"by account" - Allows you to set a virtual account value that is used to determine maximum order size based on margin settings per instrument set in the Instrument Manager

Time in force

Sets the order's time in force