OPEN-SOURCE SCRIPT

Imbalance Detector

187
The code uses a simple method to detect a Fair Value Gap (FVG) or imbalance by analyzing three consecutive candles:

Candle 1 (two candles ago)

Candle 2 (previous candle)

Candle 3 (current candle)

The logic for identifying an imbalance is based on the gaps between the candles. Specifically, it checks for one of these conditions:

Bullish Imbalance (FVG Up)

If the low of Candle 2 is higher than the high of Candle 1 and the high of Candle 3.

This suggests aggressive buying pressure, leaving an imbalance to the upside.

Bearish Imbalance (FVG Down)

If the high of Candle 2 is lower than the low of Candle 1 and the low of Candle 3.

This indicates strong selling pressure, leaving an imbalance to the downside.

📊 Visual Representation on the Chart
When an imbalance is detected, a small red triangle (plotshape) will appear on the chart above or below the candle.

The alert will trigger when the imbalance condition is true.

🚀 How to Spot the Candle
When you receive an alert, check the time of the alert and locate the corresponding candle on your 15-minute chart.

The candle marked with a red triangle is the one that triggered the alert.

Verify if it formed a Fair Value Gap by looking at the gap between the first and third candles compared to the middle candle (Candle 2).

You may also observe if the market is likely to retrace to fill the gap, which is a common price behavior.

⚙️ Criteria Summary (Simple Explanation)
Bullish Imbalance → low2 > high1 && low2 > high3

Bearish Imbalance → high2 < low1 && high2 < low3

Where:

low2 and high2 = Previous candle (Candle 2)

low1 and high1 = Candle before that (Candle 1)

low3 and high3 = Current candle (Candle 3)

👉 Example Scenario:

Candle 1 High = 1.1200, Low = 1.1180

Candle 2 High = 1.1225, Low = 1.1210

Candle 3 High = 1.1230, Low = 1.1215

Imbalance Detected: Candle 2 has a low higher than both Candle 1’s high and Candle 3’s low.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.