OPEN-SOURCE SCRIPT

Hull Trend with Cloud

This script is designed to plot two Hull Moving Averages (HMAs) and create a cloud between them, which changes color based on the trend. Here's a breakdown of what each part of the script does:

### Script Breakdown

1. **Indicator Declaration**
```pinescript
//version=5
indicator("Hull Trend with Cloud", shorttitle="HMA Cloud", overlay=true)
```
This line declares the script as a Pine Script version 5 indicator with the title "Hull Trend with Cloud" and a short title "HMA Cloud". The `overlay=true` parameter means the indicator will be plotted on the price chart.

2. **Input Parameters**
```pinescript
length1 = input.int(20, title="HMA 1 Length")
length2 = input.int(50, title="HMA 2 Length")
src = input.source(close, title="Source")
showcross = input.bool(true, title="Show cross over/under")
```
These lines define input parameters for the script:
- `length1` and `length2` are the lengths for the two HMAs.
- `src` is the data source for the HMAs, defaulting to the closing price.
- `showcross` is a boolean input to toggle the display of crossover signals.

3. **Calculate HMAs**
```pinescript
hma1 = ta.hma(src, length1)
hma2 = ta.hma(src, length2)
```
These lines calculate the two HMAs using the specified lengths.

4. **Determine Trend Direction**
```pinescript
hup = hma1 > hma1[1]
hdwn = hma1 < hma1[1]
```
These lines determine if the 20-period HMA (`hma1`) is trending up or down by comparing its current value to its previous value.

5. **Set HMA Color Based on Trend**
```pinescript
hmycolor = hup ? color.rgb(13, 235, 128) : hdwn ? color.rgb(211, 42, 19) : na
plotHMA1 = plot(hma1, color=hmycolor, linewidth=2)
plotHMA2 = plot(hma2, color=color.orange, linewidth=2)
```
These lines set the color of the 20-period HMA based on its trend direction:
- Green if trending up.
- Red if trending down.
- The 50-period HMA is plotted in orange.

6. **Create Cloud Between HMAs**
```pinescript
colorCloud = hma1 > hma2 ? color.green : color.red
fill(plotHMA1, plotHMA2, color=colorCloud, transp=75)
```
This section creates a cloud between the two HMAs:
- Green if the 20-period HMA is above the 50-period HMA.
- Red if the 20-period HMA is below the 50-period HMA.

7. **Crossover Signals**
```pinescript
crossup = ta.crossover(hma1, hma1[1])
crossdn = ta.crossunder(hma1, hma1[1])
```
These lines detect crossovers of the 20-period HMA with its previous value to generate buy and sell signals.

8. **Plot Buy and Sell Signals**
```pinescript
plotshape(series=showcross and crossup ? hma1 : na, location=location.belowbar, style=shape.labelup, color=color.green, size=size.small, text="Buy", textcolor=color.white)
plotshape(series=showcross and crossdn ? hma1 : na, location=location.abovebar, style=shape.labeldown, color=color.red, size=size.small, text="Sell", textcolor=color.white)
```
These lines plot buy and sell signals on the chart based on the crossover conditions.

### Summary
This script plots two Hull Moving Averages (20-period and 50-period) and creates a cloud between them that changes color based on the trend. It also generates buy and sell signals based on the crossover of the 20-period HMA with its previous value.

Let me know if you have any questions or need further modifications!
Hull Moving Average (HMA)

Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının yazarı komut dosyasını açık kaynak olarak yayınlamıştır, böylece yatırımcılar betiği anlayabilir ve doğrulayabilir. Yazar çok yaşa! Ücretsiz olarak kullanabilirsiniz, ancak bu kodun yayında yeniden kullanımı Ev kurallarına tabidir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?


Aynı zamanda::

Feragatname