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

Script open-source

In pieno spirito TradingView, l'autore di questo script lo ha pubblicato open-source, in modo che i trader possano comprenderlo e verificarlo. Un saluto all'autore! È possibile utilizzarlo gratuitamente, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Vuoi usare questo script sui tuoi grafici?

Declinazione di responsabilità