Skip to main content

Overview

This example shows how to build a complete trading indicator that:
  1. Fetches OHLC data from the API
  2. Detects Inside Bar patterns
  3. Generates BUY/SELL signals with Entry, Stop Loss, and Take Profit levels
  4. Uses lines to display SL/TP levels extending across multiple bars
Inside Bar Pattern: A candle where the high is lower than the previous candle’s high AND the low is higher than the previous candle’s low.

Full Python Code

How It Works

1. Inside Bar Detection

The inside bar is completely “inside” the previous (mother) bar.

2. Signal Direction

  • Bullish Inside Bar (close > open) → BUY signal
  • Bearish Inside Bar (close < open) → SELL signal

3. Signal Placement

Signals are placed 3 bars after the inside bar to:
  • Confirm the pattern
  • Avoid false signals
  • Give time for breakout confirmation

4. Risk Management

5. Lines vs Points

  • Points: Entry arrows (BUY/SELL)
  • Lines: SL and TP levels that extend 10 bars forward

Running the Example

Expected Output

Customization Ideas

Filter by Trend

Only take BUY signals when price is above 200 EMA

Add Volume Filter

Require higher than average volume on mother bar

Multiple Timeframes

Confirm signals on higher timeframe

Session Filter

Only trade during London/NY sessions

Download

Download Full Example

Get the complete code from our GitHub repository