OPEN-SOURCE SCRIPT

Composite Time Profile

124
Composite Time Profile Overlay (CTPO) - Market Profile Compositing Tool

Automatically composite multiple time periods to identify key areas of balance and market structure

What is the Composite Time Profile Overlay?

The Composite Time Profile Overlay (CTPO) is a Pine Script indicator that automatically composites multiple time periods to identify key areas of balance and market structure. It's designed for traders who use market profile concepts and need to quickly identify where price is likely to find support or resistance.

The indicator analyzes TPO (Time Price Opportunity) data across different timeframes and merges overlapping profiles to create composite levels that represent the most significant areas of balance. This helps you spot where institutional traders are likely to make decisions based on accumulated price action.

Why Use CTPO for Market Profile Trading?

Eliminate Manual Compositing Work
Instead of manually drawing and compositing profiles across different timeframes, CTPO does this automatically. You get instant access to composite levels without spending time analyzing each individual period.

Spot Areas of Balance Quickly
The indicator highlights the most significant areas of balance by compositing overlapping profiles. These areas often act as support and resistance levels because they represent where the most trading activity occurred across multiple time periods.

Focus on What Matters
Rather than getting lost in individual session profiles, CTPO shows you the composite levels that have been validated across multiple timeframes. This helps you focus on the levels that are most likely to hold.

How CTPO Works for Market Profile Traders

Automatic Profile Compositing
CTPO uses a proprietary algorithm that:
- Identifies period boundaries based on your selected timeframe (sessions, daily, weekly, monthly, or auto-detection)
- Calculates TPO profiles for each period using the C2M (Composite 2 Method) row sizing calculation
- Merges overlapping profiles using configurable overlap thresholds (default 50% overlap required)
- Updates composite levels as new price action develops in real-time

Key Levels for Market Profile Analysis
The indicator displays:
- Value Area High (VAH) and Value Area Low (VAL) levels calculated from composite TPO data
- Point of Control (POC) levels where most trading occurred across all composited periods
- Composite zones representing areas of balance with configurable transparency
- 1.618 Fibonacci extensions for breakout targets based on composite range

Multiple Timeframe Support
- Sessions: For intraday market profile analysis
- Daily: For swing trading with daily profiles
- Weekly: For position trading with weekly structure
- Monthly: For long-term market profile analysis
- Auto: Automatically selects timeframe based on your chart

Trading Applications for Market Profile Users

Support and Resistance Trading
Use composite levels as dynamic support and resistance zones. These levels often hold because they represent areas where significant trading decisions were made across multiple timeframes.

Breakout Trading
When composite levels break, they often lead to significant moves. The indicator calculates 1.618 Fibonacci extensions to give you clear targets for breakout trades.

Mean Reversion Strategies
Value Area levels represent the price range where most trading activity occurred. These levels often act as magnets, drawing price back when it moves too far from the mean.

Institutional Level Analysis
Composite levels represent areas where institutional traders have made significant decisions. These levels often hold more weight than traditional technical analysis levels because they're based on actual trading activity.

Key Features for Market Profile Traders

Smart Compositing Logic
- Automatic overlap detection using price range intersection algorithms
- Configurable overlap thresholds (minimum 50% overlap required for merging)
- Dead composite identification (profiles that become engulfed by newer composites)
- Real-time updates as new price action develops using barstate.islast optimization

Visual Customization
- Customizable colors for active, broken, and dead composites
- Adjustable transparency levels for each composite state
- Premium/Discount zone highlighting based on current price vs composite range
- TPO aggression coloring using TPO distribution analysis to identify buying/selling pressure
- Fibonacci level extensions with 1.618 target calculations based on composite range

Clean Chart Presentation
- Only shows the most relevant composite levels (maximum 10 active composites)
- Eliminates clutter from individual session profiles
- Focuses on areas of balance that matter most to current price action

Real-World Trading Examples

Day Trading with Session Composites
Use session-based composites to identify intraday areas of balance. The VAH and VAL levels often act as natural profit targets and stop-loss levels for scalping strategies.

Swing Trading with Daily Composites
Daily composites provide excellent swing trading levels. Look for price reactions at composite zones and use the 1.618 extensions for profit targets.

Position Trading with Weekly Composites
Weekly composites help identify major trend changes and long-term areas of balance. These levels often hold for months or even years.

Risk Management
Composite levels provide natural stop-loss levels. If a composite level breaks, it often signals a significant shift in market sentiment, making it an ideal place to exit losing positions.

Why Composite Levels Work

Composite levels work because they represent areas where significant trading decisions were made across multiple timeframes. When price returns to these levels, traders often remember the previous price action and make similar decisions, creating self-fulfilling prophecies.

The compositing process uses a proprietary algorithm that ensures only levels validated across multiple time periods are displayed. This means you're looking at levels that have proven their significance through actual market behavior, not just random technical levels.

Technical Foundation
The indicator uses TPO (Time Price Opportunity) data combined with price action analysis to identify areas of balance. The C2M row sizing method ensures accurate profile calculations, while the overlap detection algorithm (minimum 50% price range intersection) ensures only truly significant composites are displayed. The algorithm calculates row size based on ATR (Average True Range) divided by 10, then converts to tick size for precise level calculations.

How the Code Actually Works

1. Period Detection and ATR Calculation
The code first determines the appropriate timeframe based on your chart:
- 1m-5m charts: Session-based profiles
- 15m-2h charts: Daily profiles
- 4h charts: Weekly profiles
- 1D charts: Monthly profiles

For each period type, it calculates the number of bars needed for ATR calculation:
- Sessions: 540 minutes divided by chart timeframe
- Daily: 1440 minutes divided by chart timeframe
- Weekly: 7 days worth of minutes divided by chart timeframe
- Monthly: 30 days worth of minutes divided by chart timeframe

2. C2M Row Size Calculation
The code calculates True Range for each bar in the determined period:
- True Range = max(high-low, |high-prevClose|, |low-prevClose|)
- Averages all True Range values to get ATR
- Row Size = (ATR / 10) converted to tick size
- This ensures each TPO row represents a meaningful price movement

3. TPO Profile Generation
For each period, the code:
- Creates price levels from lowest to highest price in the range
- Each level is separated by the calculated row size
- Counts how many bars touch each price level (TPO count)
- Finds the level with highest count = Point of Control (POC)
- Calculates Value Area by expanding from POC until 68.27% of total TPO blocks are included

4. Overlap Detection Algorithm
When a new profile is created, the code checks if it overlaps with existing composites:
- Calculates overlap range = min(currentVAH, prevVAH) - max(currentVAL, prevVAL)
- Calculates current profile range = currentVAH - currentVAL
- Overlap percentage = (overlap range / current profile range) * 100
- If overlap >= 50%, profiles are merged into a composite

5. Composite Merging Logic
When profiles overlap, the code creates a new composite by:
- Taking the earliest start bar and latest end bar
- Using the wider VAH/VAL range (max of both profiles)
- Keeping the POC from the profile with more TPO blocks
- Marking the composite as "active" until price breaks through

6. Real-Time Updates
The code uses barstate.islast to optimize performance:
- Only recalculates on the last bar of each period
- Updates active composite with live price action if enabled
- Cleans up old composites to prevent memory issues
- Redraws all visual elements from scratch each bar

7. Visual Rendering System
The code uses arrays to manage drawing objects:
- Clears all lines/boxes arrays on every bar
- Iterates through composites array to redraw everything
- Uses different colors for active, broken, and dead composites
- Calculates 1.618 Fibonacci extensions for broken composites

Getting Started with CTPO

Step 1: Choose Your Timeframe
Select the period type that matches your trading style:
- Use "Sessions" for day trading
- Use "Daily" for swing trading
- Use "Weekly" for position trading
- Use "Auto" to let the indicator choose based on your chart timeframe

Step 2: Customize the Display
Adjust colors, transparency, and display options to match your charting preferences. The indicator offers extensive customization options to ensure it fits seamlessly into your existing analysis.

Step 3: Identify Key Levels
Look for:
- Composite zones (blue boxes) - major areas of balance
- VAH/VAL lines - value area boundaries
- POC lines - areas of highest trading activity
- 1.618 extension lines - breakout targets

Step 4: Develop Your Strategy
Use these levels to:
- Set entry points near composite zones
- Place stop losses beyond composite levels
- Take profits at 1.618 extension levels
- Identify trend changes when major composites break

Perfect for Market Profile Traders

If you're already using market profile concepts in your trading, CTPO eliminates the manual work of compositing profiles across different timeframes. Instead of spending time analyzing each individual period, you get instant access to the composite levels that matter most.

The indicator's automated compositing process ensures you're always looking at the most relevant areas of balance, while its real-time updates keep you informed of changes as they happen. Whether you're a day trader looking for intraday levels or a position trader analyzing long-term structure, CTPO provides the market profile intelligence you need to succeed.

Streamline Your Market Profile Analysis
Stop wasting time on manual compositing. Let CTPO do the heavy lifting while you focus on executing profitable trades based on areas of balance that actually matter.

Ready to Streamline Your Market Profile Trading?
Add the Composite Time Profile Overlay to your charts today and experience the difference that automated profile compositing can make in your trading performance.

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.