OPEN-SOURCE SCRIPT

Imbalances

This Pine Script is a trading indicator designed to identify imbalances in the market, specifically on candlestick charts. An imbalance refers to situations where there is a significant difference between buyers and sellers, which can create gaps or areas of inefficiency in the price. These imbalances often act as zones where price may return to "fill" or correct these inefficiencies.

1. Identifying Imbalances
The script analyzes candlestick patterns to detect imbalances based on the relationship between the highs, lows, and closes of consecutive candles. Specifically, it looks for:
  • Top Imbalances (Bearish): Areas where selling pressure has dominated, causing inefficiencies in the price. These are represented by patterns like multiple consecutive bearish candles or bearish gaps.
  • Bottom Imbalances (Bullish): Areas where buying pressure has dominated, leading to bullish gaps or inefficiencies.


When an imbalance is detected, the script highlights the area using visual boxes on the chart.

2. Visual Representation
The indicator uses colored boxes to show imbalances directly on the chart:
  • Top (Bearish) Imbalances: Highlighted using shades of red.
  • Bottom (Bullish) Imbalances: Highlighted using shades of green.


The boxes are further categorized into three states based on their level of mitigation:
  • Unmitigated: The imbalance has not been "filled" by price yet.
  • Partially Mitigated: Price has entered the imbalance zone but not completely filled it.
  • Fully Mitigated: Price has completely filled the imbalance zone.


3. Mitigation Logic
The concept of mitigation refers to the price revisiting an imbalance zone to correct the inefficiency:
  • If price fully or partially revisits an imbalance zone, the box's color changes to indicate the mitigation level (e.g., from unmitigated to partially/fully mitigated).
  • Fully mitigated boxes may be removed or recolored, depending on user preferences.


4. User Customization
The script provides several inputs to customize its behavior:
  • Enable or disable top and bottom imbalance detection.
  • Color settings: Users can define different colors for unmitigated, partially mitigated, and fully mitigated imbalances.
  • Mitigation display options: Users can choose whether to show fully mitigated imbalances on the chart or remove them.


5. Key Calculations
  • Imbalance Size: The size of the imbalance is calculated as the price difference between a candle's high and low across the relevant pattern.
  • Pattern Detection: The script checks for specific candlestick patterns (e.g., three consecutive bearish candles) to identify potential imbalances.


6. Practical Use Case
This indicator is useful for traders who:
  • Rely on supply and demand zones for their trading strategies.
  • Look for areas where price is likely to return (retesting unmitigated imbalances can signal potential trade setups).
  • Want to visually track market inefficiencies over time.


In Summary
The "Imbalances" indicator highlights and tracks price inefficiencies on candlestick charts. It marks zones where buying or selling pressure was dominant, and it dynamically updates these zones based on price action to indicate their mitigation status. This tool is particularly helpful for traders who use price action and market structure in their strategies.
Candlestick analysisChart patternsVolatility

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ