OB AI -- Indicator Contract
Identity
| Field |
Value |
| Pine Title |
"OB AI" |
| Study Filter |
"OB AI" |
| Overlay |
true |
| Timeframe |
Any |
Visual Channels
| Channel |
Signal Role |
Required for Strategy |
| Lines |
Primary -- order block zone boundaries (paired top/bottom) |
Yes |
| Boxes |
Primary -- FVG zones associated with order blocks |
Yes |
| Labels |
Informational -- zone sizes, fractal markers |
No (but useful) |
| Tables |
Informational -- ATR banner, FVG dashboard |
No (but useful for position sizing) |
Lines -- Order Blocks
Each order block is represented by a pair of horizontal lines at the same x-origin, defining the top and bottom of the OB zone.
Line Color Encoding
| Color Variable |
Default Value |
Meaning |
bull_line_color |
Blue (configurable) |
Bullish order block -- demand zone |
bear_line_color |
Dark red / rgb(155, 0, 0) |
Bearish order block -- supply zone |
Line Style Encoding
| Style |
Meaning |
| Solid (default) |
Active -- OB has not been touched by price |
| Dotted |
Spent -- price wick has entered the zone but did not fully mitigate |
| (deleted) |
Mitigated -- price broke through both lines; lines removed from chart (when delLines enabled) |
Line Properties
| Property |
Default |
Description |
| Width |
3 |
Line thickness in pixels |
| Length |
line_length bars (default 20) |
Horizontal span from creation bar |
| Style |
Solid |
Configurable: Solid, Dashed, or Dotted |
Pairing Rule
Two lines form an order block pair when:
- Same
x1 (same creation bar / start time)
- Same color (both
bull_line_color or both bear_line_color)
- Different
y values (different price levels)
From a valid pair:
- Top line: the line with the higher
y value = OB high
- Bottom line: the line with the lower
y value = OB low
- Midline: drawn between top and bottom at
(top + bottom) / 2, reduced opacity, same color
Order Block Zone
OB High ───────────────── (top line, bull_line_color or bear_line_color)
OB Zone
Midline - - - - - - - - - (reduced opacity)
OB Zone
OB Low ───────────────── (bottom line, same color as top)
Direction Determination
| Line Color |
OB Type |
Strategy Use |
bull_line_color |
Bullish OB (demand) |
Look for long entries when price pulls back into zone |
bear_line_color |
Bearish OB (supply) |
Look for short entries when price rallies into zone |
Boxes -- FVG Zones
Fair Value Gaps (FVGs) are drawn as semi-transparent boxes, optionally associated with order blocks.
Box Color Encoding
| Color Variable |
Default Value |
Default Transparency |
Meaning |
bullCss |
Teal |
70% |
Bullish FVG -- gap below price (demand imbalance) |
bearCss |
Black |
70% |
Bearish FVG -- gap above price (supply imbalance) |
FVG Properties
| Property |
Description |
| Top edge |
FVG high (candle 1 low for bullish, candle 3 high for bearish) |
| Bottom edge |
FVG low (candle 3 high for bullish, candle 1 low for bearish) |
| Left edge |
Creation bar |
| Right edge |
Extends with OB line_length |
FVG Midline
A dashed line drawn at the midpoint of the FVG box:
- Color and width are configurable
- Represents the 50% retracement of the gap
- Deleted when the FVG is mitigated
Standalone FVGs
When the showStandaloneFvg flag is enabled, FVGs that are not associated with any order block are also drawn. These appear as boxes without corresponding OB line pairs.
FVG Mitigation
When price fills the FVG (closes through the gap):
- The FVG box is deleted from the chart
- The FVG midline is deleted
- The associated OB (if any) may or may not be mitigated independently
OB-FVG Association
When an order block has an associated FVG, the combined zone provides multiple entry levels:
Entry Levels
| Level |
Description |
Derivation |
ob_high |
Order block top |
Higher y-value of the OB line pair |
ob_low |
Order block bottom |
Lower y-value of the OB line pair |
fvg_high |
FVG top boundary |
Top edge of the FVG box |
fvg_low |
FVG bottom boundary |
Bottom edge of the FVG box |
aggressive_fvg |
Aggressive entry level |
Middle candle edge (shallowest entry into the FVG) |
safe_fvg |
Safe entry level |
Candle 1 edge (deepest entry into the FVG) |
Bullish OB + FVG Layout
OB High ───────────────── (bull_line_color, top of demand zone)
OB Zone
Midline - - - - - - - - -
OB Zone
OB Low ───────────────── (bull_line_color, bottom of demand zone)
FVG High ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ (bullCss box top, aggressive_fvg entry)
FVG Zone
FVG Mid - - - - - - - - - (FVG midline)
FVG Zone
FVG Low ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ (bullCss box bottom, safe_fvg entry)
Relative Positioning
The FVG may overlap with, be inside of, or be adjacent to the OB zone depending on the candle structure. The above is a common layout, not a guaranteed ordering.
Spent vs. Mitigated
These are two distinct states in the OB lifecycle:
Spent
| Property |
Value |
| Trigger |
Price wick enters the OB zone (touches but does not close through) |
| Visual change |
Line style changes from Solid to Dotted |
| OB status |
Still on chart, still a potential level |
| Strategy implication |
Zone has been tested once; reduced probability but not invalidated |
Mitigated
| Property |
Value |
| Trigger |
Price breaks through both OB lines (closes beyond the zone) |
| Visual change |
Lines are deleted from chart (when delLines enabled) |
| OB status |
Removed from chart entirely |
| Strategy implication |
Zone is invalidated; no longer a valid entry |
Lifecycle
ACTIVE (solid lines)
|
price wick enters zone
|
v
SPENT (dotted lines, still visible)
|
price closes through zone
|
v
MITIGATED (lines deleted)
Labels
Size Labels
When showSizes is enabled:
| Label Text Pattern |
Position |
Meaning |
"{N}T" (e.g., "12T") |
Midpoint of OB or FVG zone, at zone end |
Zone size in ticks |
The number represents the height of the zone measured in ticks for the instrument.
Fractal Markers
When showFractals is enabled:
| Symbol |
Style |
Meaning |
| Triangle up |
label.style_triangleup |
Bullish fractal (pivot low) |
| Triangle down |
label.style_triangledown |
Bearish fractal (pivot high) |
Fractals mark the swing points used to identify order block formations.
Tables
ATR Banner
| Property |
Value |
| Position |
position.top_right |
| Layout |
1 column x 3 rows |
| Row |
Content Pattern |
Example |
Description |
| 0 |
"{ticker} \| ${risk}" |
"ES \| $102.50" |
Instrument symbol and dollar risk per contract |
| 1 |
"{stopPts}Pt \| {ticks}T" |
"2.25Pt \| 9T" |
Stop size in points and ticks |
| 2 |
"{qty} QTY" |
"2 QTY" |
Position size in contracts |
ATR Banner Parsing
Row 0: Split by " | " -> ticker (left), risk in dollars (right, strip "$")
Row 1: Split by " | " -> stop in points (left, strip "Pt"), stop in ticks (right, strip "T")
Row 2: Split by " " -> quantity (first token), literal "QTY" (second token)
FVG Dashboard (Optional)
When enabled, a separate table showing:
| Content |
Description |
| Bullish FVG count |
Number of active bullish FVGs on chart |
| Bearish FVG count |
Number of active bearish FVGs on chart |
| Mitigation % |
Percentage of FVGs that have been mitigated |
This table is informational and not required for strategy decisions.
Alert JSON
{
"instrument": "ES",
"direction": "buy",
"atrsize": 2.25,
"contractsize": 2,
"day_high": 5892.00,
"day_low": 5868.75,
"ob_high": 5878.00,
"ob_low": 5872.50,
"fvg_high": 5876.00,
"fvg_low": 5873.50,
"aggressive_fvg": 5874.75,
"safe_fvg": 5873.50
}
| Field |
Type |
Description |
instrument |
string |
Ticker symbol |
direction |
string |
"buy" or "sell" |
atrsize |
float |
ATR-based stop size in points |
contractsize |
int |
Number of contracts for position |
day_high |
float |
Current day's high |
day_low |
float |
Current day's low |
ob_high |
float |
Order block top price |
ob_low |
float |
Order block bottom price |
fvg_high |
float |
FVG top boundary |
fvg_low |
float |
FVG bottom boundary |
aggressive_fvg |
float |
Aggressive entry price (middle candle edge) |
safe_fvg |
float |
Safe entry price (candle 1 edge) |
Parser Rules
| # |
Channel |
Identifier |
Meaning |
Parser Logic |
| 1 |
Line |
color == bull_line_color, solid |
Active bullish OB boundary |
Find pairs (same x1, same color, different y). Higher y = OB high, lower y = OB low. |
| 2 |
Line |
color == bear_line_color, solid |
Active bearish OB boundary |
Same pairing logic. rgb(155,0,0) default. |
| 3 |
Line |
color == bull_line_color, dotted |
Spent bullish OB |
Zone was tested (wick entered) but not mitigated. |
| 4 |
Line |
color == bear_line_color, dotted |
Spent bearish OB |
Zone was tested but not mitigated. |
| 5 |
Line |
Midline (between paired lines, reduced opacity) |
OB midline |
Calculated: (ob_high + ob_low) / 2. Confirms pair. |
| 6 |
Box |
bgcolor matches bullCss (teal, 70% transp) |
Bullish FVG zone |
Top = fvg_high, Bottom = fvg_low. |
| 7 |
Box |
bgcolor matches bearCss (black, 70% transp) |
Bearish FVG zone |
Top = fvg_high, Bottom = fvg_low. |
| 8 |
Box |
No matching OB line pair nearby |
Standalone FVG |
Only present when showStandaloneFvg enabled. |
| 9 |
Label |
text matches "{N}T" pattern |
Zone size in ticks |
Parse integer N for zone size. Useful for filtering by minimum size. |
| 10 |
Label |
style == triangleup |
Bullish fractal (pivot low) |
Informational. Marks swing structure. |
| 11 |
Label |
style == triangledown |
Bearish fractal (pivot high) |
Informational. Marks swing structure. |
| 12 |
Table |
position == top_right, row 0 contains "\|" |
ATR banner identity |
Parse ticker, risk, stop size, quantity from rows 0-2. |
| 13 |
Line |
Deleted (absent from snapshot) |
Mitigated OB |
OB that was previously visible is now gone. Compare to prior state. |
| 14 |
Box |
Deleted (absent from snapshot) |
Mitigated FVG |
FVG that was previously visible is now gone. |
Edge Cases
| Case |
Handling |
| OB lines without matching pair |
Orphan line. May be a rendering artifact or partially off-screen. Skip. |
| Multiple OBs at similar price levels |
Each pair is distinct. Sort by x1 (creation time). Strategy typically uses the most recent. |
| FVG box overlapping multiple OBs |
Associate FVG with the OB whose x1 is closest to the FVG's left edge. |
| Spent OB later becomes mitigated |
Normal lifecycle. Dotted lines disappear. No intermediate state notification. |
delLines disabled |
Mitigated OBs remain on chart but may have visual indicators (style change). Interpreter should track state across snapshots. |
| ATR banner not visible |
Indicator may have banner disabled. Position sizing data unavailable. Strategy should use fallback sizing. |
| Zero-tick OB (top == bottom) |
Degenerate case. Skip. |
| FVG with no associated OB |
Standalone FVG (when showStandaloneFvg enabled). Valid level but lower confluence. |
| Very old OBs (beyond line_length) |
Lines may have ended (right edge reached). These are expired and should not be considered active. |
| Custom colors don't match defaults |
Interpreter must be configured with the user's chosen bull_line_color, bear_line_color, bullCss, and bearCss values. |
| Multiple instruments on same chart |
ATR banner row 0 contains the ticker. Use this to confirm the correct instrument. |