Normalized Trend Angle [Stoik]

serdar0618 · study · 34 行 · 点赞 15 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
//@version=6
indicator("Normalize Trend Açısı [Stoik]", shorttitle="Trend Açısı (Derece)", overlay=false)
 
// 1. Kullanıcı Girdileri
length = input.int(14, title="Eğim Periyodu (Bar)", minval=2)
atrLen = input.int(14, title="ATR Normalizasyon Periyodu")
 
// 2. Değişimleri Hesaplama (Delta Y ve Delta X)
// Fiyatın ne kadar değiştiğini bul ve o anki ATR'ye bölerek "Kaç birimlik (ATR) enerji harcadı?" sorusunu cevapla.
deltaY = (close - close[length]) / ta.atr(atrLen) 
deltaX = length // Geçen zaman (Bar sayısı)
 
// 3. Eğim (Slope) Hesaplama
slope = deltaY / deltaX
 
// 4. Açıyı Hesaplama (Tanjant Ters Fonksiyonu ile)
// math.atan() sonucu radyan verir, bunu dereceye çeviriyoruz (180 / Pi)
angle_rad = math.atan(slope)
angle_deg = angle_rad * (180 / math.pi)
 
// 5. Renklendirme ve Görselleştirme Mantığı
// Açı +45'ten büyükse çok güçlü Yükseliş, -45'ten küçükse çok güçlü Düşüş.
color angleColor = angle_deg > 45 ? #089981 : angle_deg > 0 ? color.new(#089981, 60) : angle_deg < -45 ? #f23645 : angle_deg < 0 ? color.new(#f23645, 60) : color.gray
 
plot(angle_deg, title="Trend Açısı", color=angleColor, style=plot.style_histogram, linewidth=3)
plot(angle_deg, title="Çizgi", color=angleColor, style=plot.style_line, linewidth=1)
 
// 6. Referans Çizgileri
hline(45, title="Güçlü Boğa (+45°)", color=color.new(#089981, 50), linestyle=hline.style_dashed)
hline(15, title="Hafif Boğa (+15°)", color=color.new(#089981, 80), linestyle=hline.style_dotted)
hline(0,  title="Sıfır Çizgisi", color=color.gray, linestyle=hline.style_solid)
hline(-15, title="Hafif Ayı (-15°)", color=color.new(#f23645, 80), linestyle=hline.style_dotted)
hline(-45, title="Güçlü Ayı (-45°)", color=color.new(#f23645, 50), linestyle=hline.style_dashed)

← 返回列表