Skip to content

TJ Alpha Signal

Component Type: ATAS C# Custom Indicator (TraderJan.Indicators)
Source Files: Alpha Signal.cs, PnLSimulator.cs
Python Parity Twin: Backtesting/backtest_reversal.py
Downstream Consumer: TJ Alpha Strategy.cs


🟢 Part 1: Layman & Trader Guide

1. What is TJ Alpha Signal?

TJ Alpha Signal (often referred to as Engine A) is an institutional-grade price action pattern detector for the ATAS Trading Platform. Unlike conventional retail indicators (like MACD or RSI) that lag price, Alpha Signal analyzes raw market microstructure: bar structure, volume intensity, and order flow delta (buying vs. selling pressure).

It does not rely on options data or external feeds. Everything is derived in real-time from the price bars on your chart (optimized for Delta and Volume bar charts, e.g., MNQ Delta 200).

2. Core Trading Setups

Alpha Signal detects two primary market behaviors:

[ Trend Phase ]  ───►  [ Reversal Exhaustion ]  ───►  [ Pullback Entry ]  ───►  SIGNAL!
(N bars in a run)        (Bar changes direction,         (Price retraces into
                          delta shows absorption)         prior bar's wick)
  1. Reversal Setup (Pullback):
  2. Trend Phase: Price moves steadily in one direction for at least $N$ candles.
  3. Reversal Phase: An exhaustion candle appears where aggressive buyers or sellers get trapped (absorption).
  4. Pullback Phase: Price briefly pulls back into the wick of the prior candle. The moment the market fails to push further against the reversal, Alpha Signal triggers an entry in the direction of the new move.
  5. Breakout Setup:
  6. Detects explosive continuation moves where high volume and extreme directional delta burst through recent ranges.

3. How to Read the Chart & HUD

When loaded on your chart: * Entry Markers: Colored arrows appear above or below the entry candle indicating the trade direction (Green for Long, Red for Short). * Price Target & Stop Loss Lines: Projected bracket lines show you where the recommended stop loss and profit target lie based on current market volatility (ATR). * Floating Performance HUD: A non-intrusive heads-up display box displays: * Total trades taken today and in the session. * Realized and unrealized PnL (ticks and dollars). * Current daily drawdown vs. your hard daily stop limit.

4. Built-in Risk Management (Trader Safety)

You do not have to guess when to stop trading. Alpha Signal includes automated risk management filters: * Volatility Gating (ATR): Blocks trades when the market is dead (flatline chop) or wildly erratic. * Daily Stop Limit: If cumulative daily loss hits your threshold (e.g., -$500), all further signals are suppressed for the rest of the day. * Breakeven & Trailing Ratchets: Once a trade moves a set number of ticks into profit, the recommended stop automatically advances to breakeven or trails the trade.


💻 Part 2: Expert & Developer Specification

1. Mathematical Architecture & Filter Pipeline

A. Reversal Pattern Invariants

A Reversal Long signal at bar $i$ requires satisfaction of the three-phase state machine: 1. Prior Trend Condition: $$\text{Consecutive Bearish Bars } \ge \text{trend_n}$$ 2. Reversal Bar Condition: $$\text{Close}{i-1} > \text{Open}{i-1} \quad \text{and} \quad \Delta_{i-1} \ge \text{req_absorption}$$ $$\text{Range}{i-1} \ge \text{min_candle_range} \quad \text{and} \quad \text{LowerWickTicks}{i-1} \ge \text{min_wick}$$ 3. Pullback Confirmation: $$\text{Low}i \le \text{Low}{i-1} + (\text{pullback} \times \text{TickSize})$$

B. Zero-Allocation Volatility Engine

To eliminate garbage collection pauses on ATAS rendering hot-paths, ATR calculation bypasses LINQ and dynamic arrays, utilizing a fixed circular buffer:

// Unmanaged circular buffer pattern
private readonly decimal[] _trBuffer = new decimal[MAX_ATR_PERIOD];
private int _bufferHead = 0;
private decimal _runningTrSum = 0m;

2. Execution Bus: 9-Series DataSeries Contract

Alpha Signal exposes an unmanaged data communication bus consumed by TJ Alpha Strategy. Strategy instances locate the indicator on the chart and subscribe to these 9 discrete series:

Series Index Name Type Value Semantics
0 SignalDirection ValueDataSeries +1.0 (Long), -1.0 (Short), 0.0 (None)
1 TargetPrice ValueDataSeries Absolute limit exit price
2 StopPrice ValueDataSeries Absolute initial protective stop price
3 TrailingOffset ValueDataSeries Ticks for dynamic trailing stop ratchet
4 BreakevenTrigger ValueDataSeries Ticks in profit required to trigger BE step 1
5 BreakevenOffset ValueDataSeries Ticks above entry to place BE stop (+1 to cover slip)
6 MaxRiskTicks ValueDataSeries Hard pre-entry risk clamp in ticks
7 DailyCircuitState ValueDataSeries 0 = Normal, 1 = Daily Loss Hit, 2 = Daily Target Hit
8 GenomeHash ValueDataSeries FNV-1a hash of active parameter genome

3. Bit-Perfect Parity Contract

To guarantee that backtests run in Python produce the exact same fills as live C# execution, Alpha Signal adheres to the Recon 4 Invariants: 1. Intra-bar SL Priority: If both Stop Loss and Take Profit fall within $[Low_i, High_i]$, Stop Loss is evaluated first. 2. CME Rollover: Session resets occur strictly at 17:00 CT. All open PnL and daily circuit limits roll over at 17:00:00.000. 3. Fill Delay & Slippage: Market entries simulate a 1-tick adverse fill penalty by default: $$\text{EntryPrice}_{\text{Long}} = \text{Close}_i + (1 \times \text{TickSize})$$

4. CSV Exporter Schema (AccountStats_AlphaSignal_*.csv)

When AutoExport is active, the indicator outputs a canonical 34-column CSV parsed by Backtesting/scripts/reconcile_trades.py:

# CLI: --trend_n 3 --rev_m 1 --pullback 2.0 --tp_mult 3.0 --sl_mult 1.5 ...
TradeId,EntryTime,ExitTime,Direction,EntryPrice,ExitPrice,PnLTicks,PnLDollars,ExitReason,MAE,MFE...