Skip to content

Add order block trading strategies and signals indicators#1

Open
iamyourmaker wants to merge 6 commits intoTradersPost:mainfrom
iamyourmaker:claude/orderblock-trading-indicator-01C3yWkiZxxmnhZCYhqp3cXW
Open

Add order block trading strategies and signals indicators#1
iamyourmaker wants to merge 6 commits intoTradersPost:mainfrom
iamyourmaker:claude/orderblock-trading-indicator-01C3yWkiZxxmnhZCYhqp3cXW

Conversation

@iamyourmaker
Copy link
Copy Markdown

Summary

This PR adds two comprehensive TradingView Pine Script tools for trading order blocks based on Smart Money Concepts (SMC) and Inner Circle Trader (ICT) methodologies.

Changes

1. Order Block Trading Strategy (order-block-smart-money-strategy.pine)

A complete automated trading strategy that:

  • Identifies bullish order blocks (strong bearish candles followed by reversals)
  • Identifies bearish order blocks (strong bullish candles followed by reversals)
  • Enters trades when price retests order block zones with confirmation
  • Implements risk management with ATR-based stop losses and configurable risk:reward ratios
  • Displays performance metrics in a real-time statistics table
  • Includes volume filtering and customizable candle size detection
  • Generates alerts for entry signals

Key Features:

  • Swing detection for identifying order block formation points
  • Automatic stop loss and take profit calculation
  • Performance tracking (win rate, profit factor, average wins/losses)
  • Visual zone highlighting and entry labels
  • Configurable parameters for different market conditions

2. Order Block Trading Signals Indicator (orderblock-trading-signals.pine)

An advanced indicator for manual and semi-automated trading that:

  • Detects market structure breaks (BOS - Break of Structure, CHoCH - Change of Character)
  • Creates and tracks multiple order blocks with mitigation detection
  • Generates entry signals when price retests unmitigated order blocks
  • Calculates dynamic take profit levels based on swing points
  • Provides three entry detection methods (Close, Wick, 50% Penetration)
  • Displays TP/SL levels with visual lines
  • Tracks active trade signals with status updates (active, TP hit, SL hit)

Key Features:

  • Custom type definitions for OrderBlock, SwingPoint, MarketStructure, and TradeSignal
  • Configurable order block construction methods (Length-based or Full candle)
  • Automatic order block cleanup to manage chart resources
  • Real-time signal status tracking with visual feedback
  • Debug mode for analyzing indicator behavior
  • Alert system for all signal events

Implementation Details

  • Both scripts use Pine Script v6 with advanced features (custom types, arrays)
  • Extensive input parameters allow customization for different trading styles
  • Visual elements include colored zones, labels, and lines for clear signal identification
  • Both tools can work independently or complement each other
  • Strategy includes position sizing (10% of equity per trade) and margin settings
  • Indicator supports up to 500 boxes, lines, and labels for comprehensive visualization

Use Cases

  • Strategy: Automated order block trading with built-in risk management
  • Indicator: Manual trading with visual order block identification and signal confirmation

https://claude.ai/code/session_01C3yWkiZxxmnhZCYhqp3cXW

iamyourmaker and others added 6 commits November 15, 2025 21:06
This indicator provides automated trading signals based on smart money order blocks
and market structure analysis. Key features include:

- Market structure detection (BOS/CHoCH)
- Volumetric order block identification
- Automated entry signals with TP/SL levels
- Risk:Reward ratio calculation
- Real-time signal status tracking
- Comprehensive alert system
- Customizable visual elements

Entry signals are generated when price returns to unmitigated order blocks
aligned with the current market structure trend.
- Fixed TradeSignal initialization: changed isBullish=na to isBullish=false
  to match expected series bool type
- Fixed calcATR scope issue: moved ATR calculation to global scope before
  conditionals to ensure it's called on every bar for consistency
- Removed redundant calcATR calls from inside conditional blocks

These fixes resolve the type mismatch and function scope errors.
The error occurred when array size was less than or equal to obShowCount,
causing an invalid loop (counting from smaller to larger with negative step).

Changes:
- Store array sizes in variables before loop to prevent recalculation
- Add safety check inside loop to prevent index out of bounds
- Add descriptive comments for clarity

This fixes: "Error: 'step' in loop must be greater than zero"
Pine Script requires the 'step' parameter to always be positive, even when
counting down. This was causing runtime errors with 'by -1'.

Solution: Replace for loops with while loops that:
- Remove items one at a time from the end of arrays
- Continue until array size matches the display count
- Simpler, clearer, and avoids step parameter issues entirely

Fixes: "Error: 'step' in loop must be greater than zero"
Visual improvements for cleaner, more professional appearance:

Order Blocks:
- Remove borders (border_color=na) for cleaner look
- Use separate extension boxes instead of extend parameter on main box
- Maintain color scheme but simplify presentation

Entry Signals:
- Simplified labels to just "LONG" or "SHORT" (removed detailed info)
- Made labels smaller (size.small) and more transparent (90% vs 80%)
- Reduced line width from 2 to 1 for subtler appearance
- Updated status labels to "LONG ✓"/"SHORT ✓" for TP hits
- Updated status labels to "LONG ✗"/"SHORT ✗" for SL hits

This matches the clean, minimal visual style of the BigBeluga indicator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants