Automatically Classify and Color STRAT 1/2/3 Candles in Real Time
Description:
Smart-STRAT is a precision candle-classifier and colorizer that applies The STRAT’s 1/2/3 logic as price unfolds. It evaluates each bar against the prior bar using strict breaks (equal highs/lows never count) to determine inside bars (1), directional bars (2up / 2down), and true outside bars (3). The indicator also tracks intra-bar order of events so it can correctly label failed 2s: if price breaks one side first and then reverses back inside the prior bar’s range without tagging the opposite side, the candle is colored as a failed 2. If it later tags both sides, it upgrades to a 3, which always takes precedence. Additionally, after a completed outside bar, the very next candle is flagged if it immediately fails that outside bar in the opposite direction. Smart-STRAT repaints the body, wick, and border for clear visibility on any chart theme, giving an at-a-glance read of structure both historically and in live markets.
Features:
-
Automatic STRAT Classification: Detects 1 (inside), 2u/2d (directional), and 3 (outside) using strict > / < comparisons; equality never counts as a break. -
Order-Aware Failed 2 Logic: Tracks which side broke first during the forming candle to mark failed 2 up or failed 2 down accurately when price returns inside without taking the other side. -
3 Takes Precedence: If a candle eventually breaks both sides, it is a 3 and remains a 3; failed-2 colors never override a true outside bar. -
Next-Bar Failure Highlight: After a completed outside bar, the following candle is colored if it immediately invalidates that outside bar’s direction. -
Full Recoloring: Body, wick, and border are colored together for clean, unambiguous visuals (no thin overlays). -
Real-Time & Historical: Works tick-by-tick as bars form and remains consistent when you scroll back. -
Minimal, Fast, Compatible: Lightweight logic designed to run smoothly across symbols and timeframes.
Parameters:
-
insideColor — Color for 1 (inside) bars. (Default: #F8E71C*)*
-
outsideColor — Color for 3 (outside) bars. (Default: #8B572A*)*
-
failedBearOutsideBarColor — Color for failed 2 down and next-bar fail after bearish 3. (Default: #BD10E0*)*
-
failedBullOutsideBarColor — Color for failed 2 up and next-bar fail after bullish 3. (Default: #50E3C2*)*
-
bullColor — Color for 2u (directional up) when no failure state applies. (Default: #00C853*)*
-
bearColor — Color for 2d (directional down) when no failure state applies. (Default: #D50000*)*
Visual Output:
-
Inside (1): Candle remains within prior bar’s high/low → painted insideColor. -
/
Directional (2u/2d): Breaks exactly one side → painted bullColor or bearColor by direction. -
Outside (3): Breaks both sides → painted outsideColor; overrides any failed-2 state. -
Failed 2 Down: Broke the low first, then returned inside without breaking the prior high → painted failedBearOutsideBarColor. -
/
-tone Failed 2 Up: Broke the high first, then returned inside without breaking the prior low → painted failedBullOutsideBarColor. -
Next-Bar Fail After a 3: The bar immediately after an outside bar that invalidates its direction is colored with the corresponding failed-outside color.
Ideal Use Case:
For traders applying The STRAT, Smart-STRAT delivers a faithful, live view of structural states and failure conditions without manual marking. It’s built for intraday and higher-timeframe analysis alike, clarifying context quickly so you can focus on execution rather than maintenance.
Contact me in discussions or at info@javadali.com for more info on this indicator.
