← Library
Pine Script v6 · Strategy · TradingView V1.0 — Level Reaction Model

Level Reaction & Doji Strategy

Structural Reversal Model — S/R Level Detection · Doji Indecision · Directional Reaction

File: level_reaction_doji_strategy.pine Type: strategy() — backtestable Capital: $100,000 initial Logic: Trend Reversal Created: Apr 19, 2026

Overview

The Level Reaction & Doji Strategy is designed to catch high-conviction market turns at structural supply and demand zones. It automates the "wait for a level, wait for a candle" workflow used by professional price action traders.

The script detects Swing Highs/Lows to establish horizontal levels, monitors for Doji candles at those levels to identify exhausted momentum, and enters only when a Reaction (follow-through) candle confirms the reversal.

Strategy Mechanics

1. Level Detection (S/R)

Uses a configurable Swing Lookback (default: 20 bars). A Resistance level is formed when a high is higher than the 20 bars before and after it. Support is formed when a low is lower than the 20 bars surrounding it.

2. Doji Indecision

A candle is flagged as a Doji if its body size is 10% or less of its total range. This represents a perfect balance between buyers and sellers, often preceding a trend change.

3. The Three-Step Trigger

StepConditionVisual Indicator
LevelPrice is within 0.2% of a detected S/R lineDashboard: "YES"
DojiCurrent candle body is ≤ 10% of rangeYellow Background / Dashboard: "✓"
ReactionNext candle closes strongly in the reversal directionBUY / SELL Label

On-Screen Visual Indicators

Real-Time Dashboard
Top-right table monitoring "Near Support," "Doji Detected," and "Entry Signal" statuses. Updates instantly on timeframe change.
Yellow Bar Zones
The background behind every Doji bar is highlighted in yellow for quick historical identification.
Structural Lines
Dynamic Red (Resistance) and Green (Support) lines that extend from detected swing points.
Signal Labels
Green "BUY" and Red "SELL" labels placed precisely at the confirmation candle close.

Risk Management (SENTINEL)

The strategy includes built-in execution logic compatible with the Vanguard engine:

NIGHTHAWK Alert Payload

When an entry condition fires, strategy.entry(alert_message=msg) delivers the following JSON as the POST body to NIGHTHAWK. All fields are required — NIGHTHAWK returns 401 if secret is missing and 500 if model_id is not registered in the SENTINEL models table.

Long Entry (BUY — Support Doji Reversal)

{ "secret": "tac_com_alpha_9", "model_id": "REACTION-DOJI-V1", "ticker": "COINBASE:BTCUSD", "action": "BUY", "price": 68240.50, "metadata": { "type": "Support_Doji_Reversal", "level": 67800.00, "timestamp": 1745000000000 } }

Short Entry (SELL — Resistance Doji Reversal)

{ "secret": "tac_com_alpha_9", "model_id": "REACTION-DOJI-V1", "ticker": "COINBASE:BTCUSD", "action": "SELL", "price": 68500.00, "metadata": { "type": "Resistance_Doji_Reversal", "level": 68500.00, "timestamp": 1745000000000 } }

Manual Test Payload (FORCE MANUAL TRIGGER)

{ "secret": "tac_com_alpha_9", "model_id": "REACTION-DOJI-V1", "ticker": "COINBASE:BTCUSD", "action": "TEST", "price": 68240.50, "metadata": { "note": "MANUAL_TRIGGER", "sup": 67800.00, "res": 68500.00, "timestamp": 1745000000000 } }
FieldDescription
secretAuth token — NIGHTHAWK returns 401 if missing or incorrect
model_idMust match SENTINEL models table record exactly — currently REACTION-DOJI-V1
tickerTradingView full symbol ID from syminfo.tickerid
actionBUY, SELL, or TEST
priceClose price at the reaction candle bar
metadata.typeSupport_Doji_Reversal (long) or Resistance_Doji_Reversal (short)
metadata.levelThe S/R level price that was respected — logged for signal analysis
metadata.timestampUnix millisecond timestamp from TradingView's timenow
Two Different Alert Types — Separate Alerts Required
  • Production signals (strategy.entry(alert_message=...)): TradingView alert condition = Order fills
  • Manual test (alert() from FORCE MANUAL TRIGGER): alert condition = Any alert() function call

3-Point Scoring Dashboard

The strategy includes a confluence scoring table in the top-right of the chart. Each of the three conditions scores one point independently — allowing you to see how close a setup is to firing even when not all conditions are met simultaneously.

Mission Condition
Status
Structural Level
Doji Signature
Reaction Breakout
Tactical Score: 3 / 3
EXECUTE
Current Bias
BULLISH
RowVariableGreen When
Structural Level (p1)at_support or at_resistance or at_support[1] or at_resistance[1]Price is or was within 0.2% of a key S/R level on current or prior bar
Doji Signature (p2)is_doji or is_doji[1]Current or prior bar qualified as a Doji (body ≤ doji_pct% of range)
Reaction Breakout (p3)bull_reaction or bear_reactionCurrent bar closed beyond the Doji's range in the reversal direction
Tactical ScoreSum of p1 + p2 + p3Shows EXECUTE (green) at 3/3, WAIT (gray) below 3
Current Biaslong_condition / short_conditionBULLISH (long), BEARISH (short), NEUTRAL (no signal)
Using the Score to Monitor Setups in Progress A score of 2/3 means a setup is developing. Watch for the third condition to complete. For example: Level hit (p1=1) + Doji formed (p2=1) = score 2/3. Now wait for the reaction candle close to confirm p3 and fire the signal.