A NinjaTrader 8 strategy that exports historical price data and EMA indicators to CSV format.
- ninjascripts/HistoricalData.cs - NinjaTrader strategy for data export
- data/HistoricalData.csv - Sample exported historical data
You MUST create a new strategy named "HistoricalData" in NinjaTrader. The strategy will not compile if you use any other name without making the necessary changes to the code.
-
In NinjaTrader 8, go to Tools → New NinjaScript → Strategy
-
Name the strategy exactly:
HistoricalData -
Click OK to create the strategy template
-
Open the newly created strategy file and replace all code with the contents of
HistoricalData.csfrom this repository -
Compile the script (F5)
-
Apply the strategy to any chart to begin exporting data
DateTime,Open,High,Low,Close,EMA21,EMA75,EMA150
01/15/2025 09:00:00,4850.25,4852.50,4848.00,4851.75,4850.12,4849.88,4848.50- OHLC price data export on bar close
- EMA 21, 75, and 150 indicators
- Configurable output path
- Error handling and data validation
MIT