NinjaTrader Integration Guide

    Complete setup, data export, and strategy deployment for NinjaTrader 8

    Complete NinjaTrader Workflow
    Applies to NinjaTrader version 8.0.19.1 64-bit
    1. Step 1: Configure NinjaTrader + import GSB AddOn
    2. Step 2: Export price data from NinjaTrader to GSB
    3. Step 3: Build GSB systems using exported data
    4. Step 4: Import GSB systems back into NinjaTrader

    Why Price Data Matters:

    Price data varies between platforms (TradeStation vs NinjaTrader). Even for the same market, timeframe, and chart type, OHLC values differ. Build GSB systems on data from the platform you'll trade on for accurate results.

    Part A: Initial Configuration

    Configure NinjaTrader 8 and import the GSB AddOn before working with price data or strategies.

    1. Import the GSB AddOn

    The GSBLib AddOn is the function library that enables GSB-built systems to work in NinjaTrader for live autotrading or simulation testing.

    Prerequisites: Download the most current version of GSB and the NinjaScript AddOn from the Resource Manager.

    Import Steps:

    1. Control Center → Tools → Import → NinjaScript Add On
    2. Navigate to GSB folders and select the most recent file (sort by Date modified)
    3. Click Open
    4. Click "Yes" if installation warning appears
    5. Click "OK" if asked to restart NinjaTrader
    6. Close NinjaTrader (save workspace if prompted)
    7. Restart NinjaTrader

    Compile the AddOn:

    1. Open NinjaScript Editor: New → NinjaScript Editor
    2. Double-click the AddOns folder (top right)
    3. Double-click the LibGSB AddOn
    4. Click Compile icon (top center)
    5. Wait for compile animation to finish (audio confirmation plays)
    6. Close editor

    Success: The AddOn is now imported and ready for use with GSB systems.

    2. Configure Options

    Time Zone Configuration

    For maximum compatibility between GSB, TradeStation, and NinjaTrader, set all platforms to US Central Time. No need to change your PC's local time—configure within NinjaTrader.

    1. Control Center → Tools → Options
    2. Categories → General
    3. Properties → Preferences → Time Zone
    4. Select: Central Time (US & Canada)

    Market Data Configuration

    Important for futures trading: While you can backtest on continuous contracts, you can't autotrade live on them. Best practice: merge historical data from prior contracts with the current contract.

    1. Options → Categories → Market Data
    2. Properties → Historical → Global merge policy
    3. Select: Merge back adjusted
    4. Click OK

    3. Trading Hours (Session Templates)

    Trading Hours are NinjaTrader's equivalent of TradeStation session templates. Create templates that match those used in TradeStation for compatibility.

    Example: Create 0830-1500 Template

    1. Control Center → Tools → Trading Hours
    2. Click "add" (bottom left)
    3. Properties → General → Name: Enter 0830_1500
    4. Sessions section → Click "add"
    5. Configure Monday session:
      • Start day: Monday
      • End day: Monday
      • Start time: 08:30 AM
      • End time: 03:00 PM
      • Check "End of Day (EOD)" checkbox
    6. Click OK
    7. Right-click below Monday session → Select "Add Monday Through Friday"
    8. Click Apply, then OK

    4. Global Simulation Mode (Safety)

    Global Simulation Mode acts as a safety catch—ensures every trade is placed in simulation mode without sending live orders. Helpful for testing, but must be disabled for live autotrading.

    Check Before Trading

    Develop a habit of checking Global Simulation Mode status before enabling strategies. It's frustrating to accidentally stay in sim mode during profitable trading periods.

    Check status: Control Center → Tools → Global Simulation Mode
    Checkmark indicates it's ACTIVE (simulation mode on)

    Part B: Exporting Price Data from NinjaTrader to GSB

    Export historical data from NinjaTrader to use in GSB Pro for strategy development.

    Step 1: Set Up Chart

    1. Open new chart: Control Center → New → Chart
    2. Configure Data Series:
      • Click Data Series icon on chart menu
      • Set Type (e.g., Minute) and Value (e.g., 30)
      • Time frame: Custom Range
      • Set Start Date (e.g., 01/01/2000)
      • Set End Date (e.g., 29/11/2019)
      • Set Trading Hours (session template: e.g., 0830_1500)
      • Click OK and wait for chart to load
    3. Show Date Range:
      • Click Properties icon
      • General → Font → Check "Show date range"
      • Date range appears in top left corner
      • Scroll chart to verify start and end dates

    Step 2: Export Price Data

    1. Add Indicator:
      • Click Indicators icon on chart menu
      • Scroll Available list to find "GSB Price Data Exporter"
      • Click "add" (bottom of Configured window)
      • Do not change any settings
      • Click OK
    2. Save Data File:
      • Save As dialog opens automatically
      • Navigate to: C:\GSB\Data\Price Data\
      • File naming convention: [Contract].[Timeframe].[BarType].[AdditionalData].txt
      • Example: ES.30.Minute.0830-1500CentralTime_1May2006-29Nov2019.txt
      • Click Save
    3. Clean Up: Remove indicator from chart. Repeat process for different contracts/dates/hours.

    Part C: Importing GSB Strategies into NinjaTrader

    Deploy your validated GSB systems on NinjaTrader for backtesting and live autotrading.

    NinjaTrader Uses C#

    Unlike TradeStation and MultiCharts which use EasyLanguage/PowerLanguage, NinjaTrader uses C# for strategy development. GSB Pro automatically generates C# code compatible with NinjaTrader 8.

    Big thank you to Jason T for his work on these docs and GSB NinjaTrader integration.

    Before You Begin: Select Your System in GSB Pro

    Before exporting to NinjaTrader, review your system's performance and ensure it meets your criteria:

    1. Review System Performance

    Examine the equity curve and key statistics to validate the system:

    GSB Pro equity curve showing system performance over time

    2. Select the System to Export

    In the Unique Systems list, identify and select the system you want to deploy on NinjaTrader:

    GSB Pro unique systems list with selected system highlighted

    3. Prepare the Strategy Code

    Switch to the Scripts tab and prepare to copy the NinjaTrader code:

    GSB Pro Scripts tab with Copy to Clipboard option for NinjaTrader code

    Pro Tip: Document the system ID, performance metrics, and data parameters before switching to NinjaTrader. You'll need these for verification after import.

    Critical Configuration: MaximumBarsLookBack Setting

    Most Common Data Issue: MaximumBarsLookBack Default Too Low
    NinjaTrader defaults to 256 bars. For GSB systems requiring more historical data, you must set MaximumBarsLookBack to Infinite.

    The Problem: NinjaTrader's MaximumBarsLookBack defaults to TwoHundredFiftySix (256 bars). Unlike TradeStation/MultiCharts which allow custom values like 500, NinjaTrader only offers two options:

    • TwoHundredFiftySix (256 bars) - Default, optimized for performance
    • Infinite - Unlimited historical data access

    How to Set MaximumBarsLookBack to Infinite:

    Method 1: In Code (Best Practice):

    Add this line in your strategy's OnStateChange() method under State.SetDefaults:

    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
            
            // Other default settings...
            Description = @"GSB Pro Trading System";
            Name = "GSB_YourSystem";
        }
    }

    Note: GSB Pro's exported NinjaTrader code may already include this setting. Verify in the generated C# code.

    Method 2: UI Settings (After Adding Strategy):

    1. Right-click chart → Indicators or Strategies
    2. Select your GSB strategy
    3. Find Maximum bars look back dropdown
    4. Change from TwoHundredFiftySix to Infinite
    5. Click Apply and OK

    When to Use Infinite:

    • GSB systems with lookback periods > 256 bars
    • Strategies using long-period moving averages (100+, 200+ period)
    • Systems with ATR, standard deviation, or volatility calculations over extended periods
    • Any indicator requiring historical data beyond 256 bars

    Alternative: BarsRequiredToTrade

    If you need exactly 500 bars (not infinite) for memory efficiency, keep MaximumBarsLookBack = TwoHundredFiftySix and add:

    if (State == State.SetDefaults)
    {
        BarsRequiredToTrade = 500; // Wait for 500 bars before trading
    }

    Then add this check in OnBarUpdate():

    if (CurrentBar < 500)
        return; // Skip until we have 500 bars

    Performance Note: Infinite uses significantly more RAM and CPU than TwoHundredFiftySix. Only use Infinite when your calculations genuinely need data beyond 256 bars.

    Step 1: Copy System ID from GSB Pro

    Now that you've selected your system, copy the system ID that you'll use in NinjaTrader:

    1. Click on the Scripts tab
    2. Select NinjaTrader 8 from the platform dropdown
    3. Copy the system ID displayed - you'll use this as the NinjaTrader strategy name

    Step 2: Open NinjaScript Editor

    1. In the Control Center, left click New → NinjaScript Editor
    Opening NinjaScript Editor from Control Center

    Step 3: Create New Strategy

    1. Click the '+' sign at the bottom of the editor to add a New Strategy
    2. The New Strategy dialog box will appear - click Next (the button with the > arrow)
    NinjaScript Editor with New Strategy button highlighted

    Name Your Strategy:

    1. In the Name field, paste the system ID you copied from GSB
    2. NinjaTrader will automatically remove spaces, dashes, etc.
    3. The name must start with a letter, so prefix it with something like "GSB"
    4. Click Generate
    New Strategy wizard with Name field and Generate button

    Step 4: Replace Template Code with GSB Code

    The NinjaScript editor will generate a strategy template. Now replace it with GSB code:

    Auto-generated NinjaScript template code before cleanup
    1. Remove pre-generated code:
      • Click on the background of the editor
      • Select all text using CTRL-A
      • Delete all text using Delete or Backspace
    Empty editor after template removal, ready for GSB code
    1. Copy GSB code:
      • Return to GSB Pro Scripts tab
      • Right click on the script background
      • Select Copy to Clipboard
    2. Paste into NinjaScript Editor:
      • Return to the NinjaScript editor
      • Right click and paste the code, or use CTRL-V
    GSB script code successfully pasted into NinjaScript Editor

    Step 5: Compile the Strategy

    1. In the top menu bar, left click the Compile icon
    Compile toolbar button highlighted in NinjaScript Editor
    1. In the lower left corner, the compile animation will play
    2. Wait for the animation to cease - an audio confirmation will play when complete
    Compile progress and success confirmation in status bar

    Success: Your GSB strategy is now compiled and ready to use in NinjaTrader.

    Step 6: Open a Chart

    1. From the Control Center, select New → Chart
    Control Center New Chart selection

    Step 7: Configure Data Series

    Configure the chart to match the data you used when building systems in GSB:

    1. On the chart toolbar, click the Data Series icon
    Data Series icon on chart toolbar
    1. Set the correct Data Series (Type and Value) to match your GSB data
    2. Set the Time frame to match your GSB data
    3. Under Time frame, select Custom Range
    4. Match the Start Date, End Date, and Trading Hours (session template) to your GSB data series
    Custom Range and time frame configuration panel

    Optional: Enable Trade Plotting

    If you want to see trades plotted on the chart after applying the strategy:

    • Under Trades, select Plot executions: Text and marker or Markers only
    Trades plot executions option in Data Series dialog

    Left click OK and wait for the chart to load.

    Step 8: Apply Strategy to Chart

    1. At the top of the chart, left click the Strategies icon
    2. Left click to select your strategy from the Available window (top left)
    3. At the bottom of the Configured window, left click add
    4. The strategy will appear in the Configured list
    Strategies dialog showing Available and Configured lists

    Configure Strategy Properties:

    The Properties fields on the right-hand side will activate. Do not click OK yet.

    Set up:
    • Account: Select the account you want to trade the strategy on
      • For back-testing, the Sim101 account is fine
      • For live trading, select a live account you've already added to NinjaTrader
    • Enabled: Ensure this checkbox is ticked
    Historical fill processing:
    • Leave Order fill resolution as Standard
    • GSB entries are not intra-bar, so high-resolution fills are not required
    • Slippage: If you added slippage in GSB settings when building systems, add that same value here
    Order handling:
    • Exit on session close: Tick this checkbox if you built systems using Exits → MOC (Market on Close): True
    • Exit on session close seconds: Default is 30 seconds. NinjaTrader will close trades 30 seconds before the end of the session. Modify if needed.
    Strategy Properties panel showing Enabled, Account, slippage, and order handling options

    Now left click OK.

    Order Confirmation: If you get an order confirmation dialog box, click OK to proceed.

    Step 9: Verify, Manage, and Analyze Strategy Performance

    After applying the strategy, go to the Strategies tab on your Control Center to verify, manage, and analyze performance. From here you can:

    • Enable and disable strategies
    • Add, edit, and remove strategies
    • Monitor multiple strategies without needing multiple charts consuming resources
    • View comprehensive performance reports by right-clicking on a strategy and selecting Strategy Performance → Historical
    Control Center Strategies tab with Strategy Performance report showing detailed statistics

    Workspaces for Strategy Monitoring

    You can set up different Workspaces to easily switch between:

    • A minimal Control Center-only strategy monitor
    • A screen full of charts with all your strategies on them

    This is a standard NinjaTrader function. See NinjaTrader help for detailed instructions.

    Performance Report Analysis:

    The Strategy Performance report shows comprehensive statistics. Here's how it maps to GSB Pro:

    • Summary: Equivalent to Performance in GSB
    • Analysis: Shows similar information to Graphs and Trades in GSB
      • Selecting Period → Trades is the same as Graphs → Trade Number in GSB
      • Selecting Periods → Daily is the same as Graphs → Trade Date in GSB
    Compare Performance

    Work through the performance report options and compare the data to the same metrics from GSB Pro. Verify that the backtest results match within acceptable variance before proceeding to live trading.

    Going Live: Automated Trading

    Before Enabling Automation

    Critical pre-flight checklist:

    • Backtest results verified and match GSB Pro within acceptable variance
    • Commission and slippage modeled realistically
    • Position sizing appropriate for account size
    • Risk management rules properly configured
    • Simulated trading tested for minimum 2 weeks
    • Real-time data feed connected and verified
    • Broker connection stable and authenticated

    NinjaTrader-Specific Settings

    Calculate Mode

    Choose when strategy calculations occur:

    • On bar close: Most reliable, processes complete bars only (recommended for most systems)
    • On each tick: Real-time updates, useful for scalping but can generate false signals
    • On price change: Updates on price changes, middle ground option

    Order Handling

    Configure how orders are managed:

    • Entry handling: All entries, Unique entries only
    • Exit handling: ImmediatelySubmit, ImmediatelySubmitSynchronizeAccount
    • Entry execution: Market, Limit, Stop orders

    Common Issues and Solutions

    Compilation Errors

    If strategy won't compile:

    • Ensure GSB_Indicators add-on was imported first
    • Check NinjaScript Editor for specific error messages
    • Verify NinjaTrader version is 8.0 or later
    • Try removing and re-importing both the indicators and strategy

    Performance Discrepancies

    If backtest doesn't match GSB Pro:

    • Verify "Calculate" mode matches your system design
    • Check that bar type and interval match exactly
    • Ensure session template matches (24-hour vs regular trading hours)
    • Review commission and slippage settings
    • Compare data sources (different data can produce different results)

    Real-Time Execution Issues

    If live/sim trading behaves differently than backtest:

    • Check "Calculate" mode - use "On bar close" for consistency
    • Verify data feed is stable and not missing ticks
    • Review order fill assumptions (market orders may slip)
    • Monitor NinjaTrader's log tab for errors or warnings

    Additional Resources

    Next Steps

    If you encounter issues with your exported strategies, check the troubleshooting guide: