Levels

Title: Swing Levels with Chop Detection and Hold Alerts
This indicator draws horizontal levels from confirmed swing highs and lows, ends levels when repeated candle crossings indicate choppy price action, and supports real-time alerts after a touch followed by sustained price holding.
Automatic levels
Swing highs and lows are identified using configurable numbers of candles to the left and right of the pivot. An optional ATR(14) filter requires a minimum price move away from the pivot on both sides, helping reduce minor swing levels.
Each level is drawn as an independent horizontal segment. The history limit controls how many automatic levels are retained, including completed segments.
Chop detection
A crossing is counted when a closed candle’s low is strictly below the level and its high is strictly above it. A touch without crossing does not count.
When the number of crossing candles exceeds the configured allowance within a rolling time window, the level ends at that candle’s close. For example, with a 60-minute window and an allowance of 3 candles, the fourth crossing ends the level.
Completed levels remain visible until removed by the history limit, but no longer extend or trigger alerts.
Manual levels
Up to six manual price levels can be enabled in the indicator settings. Automatic levels can also be excluded by entering their prices in a semicolon-separated list.
Manual levels can optionally follow the same chop termination rule. They are calculated from the beginning of the loaded chart history, so historical crossings may end them before the current candle.
Real-time hold alerts
Alerts apply only to active levels:
• After approaching from below and touching or crossing a level, price must remain at or above it for longer than the configured hold duration.
• After approaching from above, price must remain at or below it.
• A return to the original side resets the timer.
The default hold duration is more than 10 seconds. Touch tolerance and the minimum interval between repeated alerts are configurable.
To enable notifications, create an alert with the condition “Any alert() function call”, then select the desired sound and notification options. One alert monitors all active levels for its selected symbol and timeframe.
Confirmation delay and limitations
Pivot levels become available only after the required right-side candles have closed. Lines are anchored to the original pivot candle, so their historical starting points precede the time the levels were actually confirmed.
Second-based holding is evaluated only in real time when price updates arrive. It cannot be reconstructed from historical candles, and a signal is generated on the first update after the hold duration has been exceeded.
The indicator reads manual levels entered through its own settings; it does not read TradingView drawing objects.
Use an intraday timeframe. Recreate the alert after changing indicator settings, manual prices, code, symbol, or timeframe, because an existing alert retains the configuration captured when it was created.
This indicator draws horizontal levels from confirmed swing highs and lows, ends levels when repeated candle crossings indicate choppy price action, and supports real-time alerts after a touch followed by sustained price holding.
Automatic levels
Swing highs and lows are identified using configurable numbers of candles to the left and right of the pivot. An optional ATR(14) filter requires a minimum price move away from the pivot on both sides, helping reduce minor swing levels.
Each level is drawn as an independent horizontal segment. The history limit controls how many automatic levels are retained, including completed segments.
Chop detection
A crossing is counted when a closed candle’s low is strictly below the level and its high is strictly above it. A touch without crossing does not count.
When the number of crossing candles exceeds the configured allowance within a rolling time window, the level ends at that candle’s close. For example, with a 60-minute window and an allowance of 3 candles, the fourth crossing ends the level.
Completed levels remain visible until removed by the history limit, but no longer extend or trigger alerts.
Manual levels
Up to six manual price levels can be enabled in the indicator settings. Automatic levels can also be excluded by entering their prices in a semicolon-separated list.
Manual levels can optionally follow the same chop termination rule. They are calculated from the beginning of the loaded chart history, so historical crossings may end them before the current candle.
Real-time hold alerts
Alerts apply only to active levels:
• After approaching from below and touching or crossing a level, price must remain at or above it for longer than the configured hold duration.
• After approaching from above, price must remain at or below it.
• A return to the original side resets the timer.
The default hold duration is more than 10 seconds. Touch tolerance and the minimum interval between repeated alerts are configurable.
To enable notifications, create an alert with the condition “Any alert() function call”, then select the desired sound and notification options. One alert monitors all active levels for its selected symbol and timeframe.
Confirmation delay and limitations
Pivot levels become available only after the required right-side candles have closed. Lines are anchored to the original pivot candle, so their historical starting points precede the time the levels were actually confirmed.
Second-based holding is evaluated only in real time when price updates arrive. It cannot be reconstructed from historical candles, and a signal is generated on the first update after the hold duration has been exceeded.
The indicator reads manual levels entered through its own settings; it does not read TradingView drawing objects.
Use an intraday timeframe. Recreate the alert after changing indicator settings, manual prices, code, symbol, or timeframe, because an existing alert retains the configuration captured when it was created.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.