Intrabar Lab
System · NinjaTrader 8 · Python · Flask

A trading pipeline from NinjaTrader to the web

Every closed trade leaves NinjaTrader with its chart screenshot and full details, lands in a database, and shows up seconds later in a journal with a calendar and statistics. The same server stores market bars and options-gamma snapshots, and sends live signals back to NinjaTrader.

How the pieces connect

One Flask server sits between the trading platform, a Python signal engine and the browser. Each arrow is an HTTP request with a defined format.

NinjaTrader 8 C# NinjaScript Strategiesscreenshot + trade data on exit Bar capture indicator5-minute OHLCV Signal receiver add-onpolls, places, confirms fills Flask server REST API · Python /screenshots/upload /market/bars /gex/upload /signals/pending · /ack · /fill /signals/submit /tvwebhook image + fields bars poll / fill Python live enginedetects setups, submits signals Options gamma dataGEX snapshots, alerts Storage SQLite: trades, bars, access log Images + auto thumbnails Web dashboard Gallery by strategy Calendar heatmap Weekday / month statistics CSV export · admin · login Remote access via ngrok tunnel

Capture

On every exit, the strategy uploads the chart image with instrument, account, entry and exit times in local and UTC, prices, exit reason and net P&L.

Store

The server validates each upload, writes it to SQLite, saves the image and builds a thumbnail. Bars and gamma snapshots are stored per symbol and day.

Analyze

The dashboard groups trades by strategy, colours each calendar day by win rate, and breaks results down by weekday and month. Everything exports to CSV.

Execute

A Python engine posts signals. The NinjaTrader add-on polls for them, places the order and reports the fill back, so every signal has a status.

The trade journal

Sample data. These trades are generated for the demo and are not real results.

This is a working copy of the journal's calendar view. Pick a day to see its trades. The statistics view follows below.

Month

Days are coloured by win rate: green above 50%, red below 50%. Stronger colour means further from 50%.

Pick a day

Select a coloured day in the calendar to list its trades.

Weekday performance

Strategy folders

Statistics by strategy and instrument

Same sample trades as the calendar above.

The statistics view ranks every strategy by net result, with win rate, profit factor and average trade, and shows which instruments each one traded. Strategies marked as restricted keep their numbers but hide their name from visitors without access.

Strategies

Instruments

Profit factor = gross profit ÷ gross loss. Sample results include commissions per contract.

The main endpoints

EndpointWhat it does
POST /screenshots/uploadNinjaTrader sends a trade: chart image plus entry, exit, prices, exit reason and P&L.
GET /screenshots/api/calendar_statsDaily trade counts, win rate and net result for the calendar.
GET /screenshots/export/csvEvery trade as a CSV file for outside analysis.
POST /market/barsNinjaTrader streams 5-minute bars per symbol.
GET /market/backtest/<symbol>Bars merged with the gamma snapshot of the day, marked above or below the gamma flip.
POST /signals/submitThe Python engine publishes a new signal.
GET /signals/pendingThe NinjaTrader add-on collects signals to place.
POST /signals/<id>/fillNinjaTrader confirms the fill, closing the loop.

Built with Python, Flask, SQLite and Pillow on Linux, with C# NinjaScript on the trading side.

The architecture, the trading strategies and the signal logic are my own design. The code was written with AI assistance, and I verified each piece before relying on it.