PROTECTED SOURCE SCRIPT

Positive/Negative Close Counter (Bar-Based)

27
# Positive/Negative Close Counter (Bar-Based)

## Overview
This indicator analyzes the historical performance of an asset by counting positive and negative closing price movements over a specified lookback period. It provides statistical insights into the directional bias of price action, helping traders understand the historical tendency of an instrument to close higher or lower compared to the previous period.

## Key Features
- **Multi-Timeframe Analysis**: Supports Daily (D) and Weekly (W) timeframe analysis
- **Customizable Lookback Period**: Adjustable lookback period with default setting of 252 bars (approximately 1 trading year for daily charts)
- **Flexible Display Options**: Choose from 5 different label positions on the chart for optimal visibility
- **Real-Time Statistics**: Displays count of positive closes, negative closes, and percentage of positive movements
- **Clean Visual Presentation**: Information displayed in a clear, organized label with emojis for easy reading

## Input Parameters
1. **Timeframe**: Select between Daily or Weekly analysis
2. **Lookback Period**: Number of bars to analyze (default: 252 bars)
3. **Display Box Location**: Choose label position from Top Left, Top Right, Bottom Left, Bottom Middle, or Bottom Right

## What It Shows
The indicator displays:
- Current timeframe being analyzed
- Number of bars in the lookback period
- Count of periods where the close was higher than the previous close (Positive Closes)
- Count of periods where the close was lower than the previous close (Negative Closes)
- Percentage of positive closing periods

## Technical Implementation
- Uses Pine Script v5 for optimal performance
- Implements security() function for multi-timeframe data requests
- Employs dynamic label positioning based on visible price range
- Handles edge cases with proper null value checking

## Important Notes
- The indicator only counts closes that are definitively higher or lower than the previous close
- Unchanged closes (equal prices) are not counted in either category
- Results are based on historical data and do not predict future performance
- Works on all chart timeframes but analyzes data according to the selected timeframe parameter

This tool is designed for educational and analytical purposes to help traders better understand price behavior patterns in their chosen instruments.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.