OPEN-SOURCE SCRIPT

Multiple Swing High/Low with SL

Explanation:
Swing Highs and Lows:

The script detects swing highs and swing lows using ta.pivothigh() and ta.pivotlow() on a 3-minute basis.
Each swing high is drawn with a green line, and each swing low is drawn with a red line.
Stop-Loss (SL) Lines:

For each swing high, a stop-loss line is drawn 15 points below the swing high.
For each swing low, a stop-loss line is drawn 15 points above the swing low.
The SL line for swing highs is drawn in red, and the SL line for swing lows is drawn in blue.
Labels for Swing High/Low and SL:

Labels with text like "Swing High" or "Swing Low" are added at the swing points, and SL labels are added at the stop-loss levels.
These labels can be toggled on/off using the showSwingTags input.
Line Extension:

The line.set_x2() function ensures that the swing lines and SL lines are extended to the current bar as price moves.
Key Changes:
Removed Arrays: Instead of using arrays to store lines and labels, we now handle each line and label individually. This avoids the issue where complex types (line and label) were being stored in arrays, which Pine Script doesn't support directly.
Dynamic Creation: New lines and labels are dynamically created as new swings occur, and they stay on the chart until the script is removed or the chart is reloaded.
Bill Williams IndicatorsBreadth IndicatorsCandlestick analysisswingswinghighswingsetupswing-tradingswingtrading

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian