Ready to go further
Next: read about overfitting
It explains why the top optimizer row disappoints.
What is included
- What it is, in plain words
- The formula or mechanism, with exact arithmetic
- How it hits grid, martingale and DCA bots
- A check you can run before you switch a bot on
Who it is for
- People who run or plan to run a trading bot
- Anyone reading a backtest or a bot sales page
- Readers who want the numbers, not the pitch
- Not advice, and not a signal service
Key facts
- NinjaTrader is a platform where a bot or strategy is written, tested and run. This page explains the general method, not the product's current features.
- A bot is only as trustworthy as its test. Before relying on any result here, check costs, fills, data and timing, and keep a stretch of data the rule never saw.
- The worked example on this page uses made-up numbers, checked in node on 31 Oct 2026. It shows the arithmetic, not how any product performs.
- Prices, fees, markets, versions, limits and supported languages change and belong to the vendor. We state none of them. Check the vendor's current pages.
- Start on a simulated account, keep stops where they still work if the bot stops, and move to real money only in very small steps, if at all.
What it is
NinjaTrader is a charting, testing and order platform for futures and other markets. The general design, shared by a few platforms, is a charting application that also lets you write strategies in a general programming language. For this kind of platform that language is C# on the .NET framework, and the strategy is a class with methods the platform calls as new data arrives.
Because it is real code, the strategy can be as simple as a crossover or as complicated as a multi-instrument system. The cost of that freedom is that the platform will run whatever you write, including mistakes. Specific features, markets, pricing and licence terms are the vendor's to state and they change, so check the vendor's current pages. This page explains how it works in general terms. We have not tested it for this page. Check the vendor's current terms.
How a bot connects here
The connection style is built-in scripting with a full language. The strategy runs inside the platform process, receives bar or tick events and submits orders through the platform's own order methods. The platform manages the connection to the broker or data provider.
- Event driven. Your code is called when a bar closes, or on each tick, depending on a setting. The same code can behave very differently under each.
- An optimizer. Platforms of this kind include a tool that runs the strategy over many parameter combinations and ranks them. This is powerful and is the most common source of overfitting.
- Order management inside the code. Entries, stops and targets are things your code must submit and track. A bug here is a trading bug.
- Simulated and live accounts. A simulated account normally exists for practice. Check what the vendor currently offers and how it models fills.
Worked example: how an optimizer finds luck
Suppose you let an optimizer try a fast period on 5 values, a slow period on 8 values and a stop distance on 5 values. That is 5 x 8 x 5 = 200 combinations. Now imagine the rule has no edge at all, so every combination is a coin flip. If you rank the results, the top 5 percent are the ones that looked best by luck. The table gives the chance that at least one of k independent combinations lands there. Made up and exact, 31 Oct 2026.
| Combinations tried | Expected in the lucky top 5 percent | Chance at least one is |
|---|---|---|
| 1 | 0.1 | 5% |
| 10 | 0.5 | 40.1% |
| 50 | 2.5 | 92.3% |
| 200 | 10.0 | 100.0% |
At 200 combinations you expect about 10 lucky results, and the chance of at least one is 99.996%. Real grids are not fully independent, because neighbouring settings behave alike, so the true count of independent tries is smaller. The point stands: the more settings you try, the more certain a flattering winner becomes, whether or not the rule works. The fix is to look for broad plateaus where many nearby settings all do acceptably, and to test the pick on data it never saw. See overfitting.
What to verify before trusting a backtest here
These checks apply to any platform of this kind. The answers come from the vendor's current documentation and from your own tests, not from this page.
| Check | Why it matters |
|---|---|
| Calculation timing (bar close or each tick) | The backtest and the live run must use the same setting. |
| Fill settings and slippage | Read how limit and stop orders are filled in the test and enter honest costs. |
| Optimizer settings you tried | Count every combination. The count is part of the result. |
| Out of sample period | Keep a final stretch of data the optimizer never touched. |
| Historical data source and gaps | Tick, minute and daily data behave differently. Check how far back it goes. |
| Session and time zone handling | A rule tied to a time of day breaks if the session template is wrong. |
How bots break on this kind of platform
- Overfitted parameters. The best optimizer row is rarely the best live row.
- Order state bugs. The strategy believes a stop is working when it was rejected or cancelled.
- Same code, different timing. A strategy tested on bar close that is run on every tick is a different strategy.
- Platform or computer down. The strategy runs on your machine. Without a stop held at the broker, an outage leaves a position unguarded.
- Data differences. The feed you test on and the feed you run on may print different prices.
A safe order of work
Backtest with honest costs, forward test on new data, run on a simulated account for weeks, then trade a very small size and compare each step with the one before. See forward testing and paper trading.
What this page does not tell you
It does not tell you whether the product is suitable, what it costs, or how it behaves today. Those change and belong to the vendor. It does not give a strategy to trade. This page explains how it works in general terms. We have not tested it for this page. Check the vendor's current terms.
Keep Going
Related Tools and Guides
Keep exploring
FAQ
Frequently Asked Questions
What language is used to write NinjaTrader strategies?
Platforms of this kind use C#. Check the vendor for the current framework and any other options.
Is optimizing a strategy the same as testing it?
No. Optimizing searches for the best settings on past data. Testing means checking the chosen settings on data the search never saw.
Does a good NinjaTrader backtest mean a bot will make money?
No. A backtest shows how a rule behaved on past data under its assumptions. Costs, fills, data and luck can all make live results different.
Should I test on a simulated account before real money?
Yes, as a general practice. A simulated account tests your code and your plumbing. Its fills are usually kinder than real ones, so it does not prove a rule works.
Have you tested NinjaTrader?
No. This page explains how it works in general terms and we have not tested it for this page. Check the vendor's current terms.
Are the numbers on this page real?
Example numbers are made up to show how the maths works, and the page says so. A figure only counts as exact when the page says it was calculated on a stated date. Nothing you enter in a calculator leaves your browser.
Can I use this to decide whether to run a bot?
It can show whether a bot's numbers hold together and how much an account can lose. It cannot say what the market will do, and it is not advice. Use it to ask better questions, then read the terms of your own broker or exchange.
Is this financial advice?
No. It is general education. The numbers are made up and it does not consider your situation.
Know the Risk Before You Run It
Free calculators and guides, added every week. Leave your details and we will email you when new ones go up.
Trading carries a risk of loss