TradeReign
Back to HomeEducation HubCompatibilityAboutDisclosures
NinjaTrader Desktop Guide

NinjaTrader Strategy Builder Test a No-Code Signal Before Adding Orders

NinjaTrader’s 8.1.9 documentation shows both AI and guided builders. Use the guided builder here so you can inspect each condition, choose a one-bar lookback and check exactly when the action fires.

Quick Answer

In NinjaTrader Desktop, go to Control Center → New → Strategy Builder. If you see a product chooser, select Strategy Builder for the guided Classic workflow. This exercise calculates on bar close and prints a message when the 9-period SMA crosses above the 20-period SMA. The print action sends no orders.

Start 7-Day TrialSet up the signal in ClassicCompare 1- and 3-bar crossover lookbacksTest one contract with a stop and targetDiagnose zero trades

Build one condition and a Print action in Strategy Builder

Open Strategy Builder in the Control Center. The current desktop guide uses the New menu and describes a compile check before the product chooser. If that check reports an error, resolve it in NinjaScript Editor before continuing.

  1. Choose the guided builder and create a strategy named SmaCrossPrintDemo. Set Calculate to On bar close in Default Properties. Use one input series for the exercise.
  2. In Conditions and Actions, add one condition. On the left, select Indicator → SMA with Period 9. On the right, select SMA with Period 20. Use the same input series and set Cross above with Look back period 1.
  3. Under Actions, add Misc → Print. In the message editor, enter a recognizable label such as 9 SMA crossed above 20 SMA. Include the signal bar’s time if you want to match output to the chart. Leave order actions, stops and targets empty in this copy.
  4. Select Finish to compile. Open New → NinjaScript Output before enabling the compiled strategy on a chart with a simulation account selected. Use one dated contract, one-minute bars and enough prior bars for both averages.

Compare 1- and 3-bar crossover lookbacks

These fictional MES bars illustrate what to check in NinjaScript Output. The 9-period SMA crosses above the 20-period SMA at the 9:56 close. Cross above with a lookback of 1 prints at 9:56 only. With a lookback of 3, it can print at 9:56, 9:57 and 9:58 because each window still contains that same cross. At 9:59 the cross has left the window. A Greater comparison would still be true at 9:59 because the fast average is above the slow average.

The SMA values use closing prices and are rounded for display. NinjaTrader’s CrossAbove reference says exact equality on the current or previous bar prevents a true result with a lookback of 1. If the chart values look equal after rounding, compare the unrounded values in your diagnostic output.

One-minute MES crossover example

Synthetic MES 1-minute candles. Times are bar closes in ET.

Marked bars · 9:56 1

The blue line is the 9-period SMA and the gold line is the 20-period SMA. Marker 1 is the first completed bar where the blue line crosses above. The following two bars remain above without another cross.

Expected Print output by crossover lookback
Close9 SMA20 SMA1 bar3 bars
9:555,997.7505,998.025NoNo
9:565,998.0835,998.063YesYes
9:575,998.4725,998.125NoYes
9:585,998.9175,998.213NoYes
9:595,999.3335,998.325NoNo

Make a second Print-only copy and change only Look back period to 3. Give its message a distinct label and include the bar time in both copies. Run them on the same dated contract, one-minute chart, session and history. Compare the three consecutive prints with the single marker on the chart before adding any order action.

Turn the signal into a one-contract backtest

Keep the Print-only strategy so you can repeat the signal check. Build a second strategy named SmaCrossOrderDemo with the same SMA inputs, one-bar lookback and On bar close calculation. Use Strategy Analyzer for the order test.

  1. In Conditions and Actions, use If All and add a condition that the strategy position equals Flat. Keep the Print action and add a long market entry from Order Management to the same set. Set quantity to 1 and name the entry SmaCrossLong so you can find it in the results.
  2. In Stops and Targets, add a fixed stop loss of 8 ticks and a profit target of 12 ticks. Use Ticks for both. If the MES entry fills at 6,000.25, the stop price is 5,998.25 and the target price is 6,003.25. These are sample order prices. The actual stop execution can differ from its trigger.
  3. Select Finish to compile. In Control Center → New → Strategy Analyzer, select Backtest and pick the new strategy. Use the same dated MES contract, one-minute bars, Trading Hours template and test period as your signal check, with enough earlier data for the averages. Record the commission, slippage and fill resolution settings so you can rerun the same test.
  4. Find the first printed signal and compare its time with the entry execution in the results. Check the entry fill price before calculating the expected stop and target. If your first signal printed at 9:56 but the simulated trade opened later or at a different price, compare the bar-close signal with the Analyzer’s historical fill settings before changing the crossover.

Diagnose a strategy that shows zero trades

This Print-only exercise should produce zero trades. Look for the signal message in NinjaScript Output first. If there is no message, check that the strategy compiled and is enabled, the chart has loaded enough history, and a qualifying cross occurs within the data shown. Compare the selected price inputs, SMA periods, bar type and Calculate setting.

Keep the Print example as a baseline. In the order-enabled copy, open Default Properties → More properties and enable Trace orders. Compile, clear NinjaScript Output, and rerun one short backtest with the same contract, Trading Hours template, and bar interval. Keep the timestamped Print in the same condition set as the entry and use the entry signal name to match it to the trace.

  1. No signal print. If the Print-only copy shows the 9:56 cross and the order copy is silent, compare the full condition set. A new Flat condition can make the result differ even with identical SMA inputs. Verify the strategy position and the input values at that bar.
  2. Signal print, but the entry is absent or ignored. Confirm the entry action is in the same condition set. If a trace gives an ignore reason, investigate that reason first. Also check Minimum bars required. In a test where the first cross arrives on the 27th processed bar, a setting of 40 can prevent an entry there even though the averages are already calculable. Load more history before the cross and rerun with the same minimum to test that explanation.
  3. Entry submitted, no fill. Check the order type, price and how long it worked. For a separate test, suppose the strategy submits a buy limit at 6,000.25 after 9:56 and the lowest simulated price while it works is 6,000.50. The market stays one MES tick above the limit. A later trade at 6,000.25 can matter only if the order is still working then. Check the order trace before changing the signal or the historical fill settings.
Sources

Official References

Platform details on this page were checked against these official resources.

NinjaTrader Strategy Builder overviewVerify the Control Center menu and builder choices.Strategy Builder Classic screensSee Default Properties, Conditions and Actions, and Finish.Strategy Builder order actionsVerify the entry type, order quantity and signal name.NinjaTrader backtest settingsCheck the historical fill model, commission and slippage controls.Strategy Builder Condition BuilderCheck cross operators, lookback and indicator inputs.NinjaTrader CrossAbove referenceCheck the one-bar lookback and equality behavior.NinjaTrader debugging with Print and TraceOrdersFind the guided Print action and check what to inspect after a signal.NinjaTrader Minimum bars required referenceCheck when the historical bar requirement permits order processing.
Related Guides

Keep Building the Rule System

Use NinjaTrader’s AI Strategy Builder

Compare the prompt-based workflow and check its generated backtest settings.

Backtest a strategy in NinjaTrader Strategy Analyzer

Match your contract and session, then inspect commissions, slippage and fill assumptions.

Find the simulation account in NinjaTrader

Verify the account and environment before practicing.

Understand NinjaTrader strategy start behavior

Compare account position, strategy position and the settings used when a strategy starts.

FAQ

Common Questions

Where is Strategy Builder in NinjaTrader Desktop?

Use Control Center → New → Strategy Builder. If the product picker appears, select the guided Strategy Builder for the Classic editor.

Do I need to unlock NinjaScript to use Print?

Add Misc → Print in the guided builder’s Actions list. NinjaTrader says an unlocked strategy can no longer be edited in the guided builder.

Can I check signals before simulating orders?

Yes. Attach a Print-only strategy to a simulation chart and inspect NinjaScript Output. An order-enabled copy is needed for the Analyzer to report trades.

Risk Disclosure

Futures trading contains substantial risk and is not suitable for every investor. TradeReign is a trading-discipline and rule-enforcement application. It does not provide trading advice, trade signals, investment recommendations, or performance guarantees.

TradeReign is not a broker-dealer, futures commission merchant, or investment advisor.

Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Only risk capital - money that can be lost without jeopardizing financial security or lifestyle - should be used for trading. Past performance is not necessarily indicative of future results.