OPEN-SOURCE SCRIPT
Telah dikemas kini

Chattes-SwingCount

44
Chattes-SwingCount
// This indicator detects swings using a custom ZigZag algorithm and calculates:
// - Average pip movement per swing
// - Standard deviation of pip movement
// - Average number of candles per swing
// - Standard deviation of candle count
//
// The stats are displayed in a compact box at the top-right corner of the chart.
//
// An alert is triggered when a swing's pip size exceeds 1.5× the standard deviation,
// helping identify unusual volatility or significant market moves.
//
// Inputs allow customization of ZigZag detection parameters and swing sample size.
Nota Keluaran
1. Anchored the stats box to the top of the chart by replacing yloc=yloc.price with yloc=yloc.abovebar, which positions the label above the bar regardless of
the y-coordinate.
2. Removed the topY calculation (which was previously using ta.highest(high, 100)) since it's no longer needed with the new anchoring approach.
3. Changed the font size from size.large to size.small to make the stats box less intrusive while still providing the swing statistics.
4. Simplified the label positioning code to only update the x-position with label.set_x() rather than both x and y, since the y-position is now automatically
handled by the yloc.abovebar setting.
5. Added a clarifying comment to explain that we're keeping the label at the right edge of the chart.

These changes ensure the stats box now stays fixed in the top-right corner of the chart and updates its position and content as new data becomes available.

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.