Untitled
unknown
plain_text
23 days ago
5.7 kB
5
Indexable
Never
//@version=5 indicator("Velocity Acceleration Indicator [CC]", overlay = true) // Request Security Fonksiyonu requestSecurity(string _symbol, string _res, float _src, bool _repaints) => repIndex = _repaints ? 0 : barstate.isrealtime ? 1 : 0 resIndex = _repaints ? 0 : barstate.isrealtime ? 0 : 1 result = request.security(_symbol, _res, _src[repIndex]) var GRP1 = "General Settings" float inp = input(title = 'Source', defval = hlcc4, group = GRP1) string res = input.timeframe(title = "Resolution", defval = "", group = GRP1) int length = input.int(title = "Length", defval = 21, minval = 2, maxval = 60, step = 1, group = GRP1) int smoothLength = input.int(title = "Smoothing Length", defval = 5, minval = 1, maxval = 9, step = 1, group = GRP1) bool rep = input.bool(title = "Allow Repainting?", defval = false, group = GRP1) bool bar = input.bool(title = "Allow Bar Color Change?", defval = true, group = GRP1) // Sayılar için ayrı input'lar var GRP2 = "Number Visibility Settings" bool show1 = input.bool(title = "Show 1?", defval = true, group = GRP2) bool show2 = input.bool(title = "Show 2?", defval = true, group = GRP2) bool show3 = input.bool(title = "Show 3?", defval = true, group = GRP2) bool show4 = input.bool(title = "Show 4?", defval = true, group = GRP2) bool show5 = input.bool(title = "Show 5?", defval = true, group = GRP2) bool show6 = input.bool(title = "Show 6?", defval = true, group = GRP2) bool show7 = input.bool(title = "Show 7?", defval = true, group = GRP2) bool show8 = input.bool(title = "Show 8?", defval = true, group = GRP2) bool show9 = input.bool(title = "Show 9?", defval = true, group = GRP2) float src = requestSecurity(syminfo.tickerid, res, inp, rep) // Velocity hesaplamaları calculateVelocity(float _src, int _length) => float velAccSum = 0 for int i = 1 to _length velAccSum += (_src - nz(_src[i])) / i float velAccAvg = velAccSum / _length float velocityAvg = ta.wma(calculateVelocity(src, length), smoothLength) float accelerationAvg = calculateVelocity(velocityAvg, length) // Hız ve ivme değerleri hline(0) float slo = accelerationAvg - 0 int sig = slo > 0 ? slo > nz(slo[1]) ? 2 : 1 : slo < 0 ? slo < nz(slo[1]) ? -2 : -1 : 0 color vaiColor = sig > 1 ? color.blue : sig > 0 ? color.blue : sig < -1 ? color.black : sig < 0 ? color.black : na // Bar rengi barcolor(bar ? vaiColor : na) plot(accelerationAvg, "Velocity Acceleration Avg", vaiColor, linewidth = 2, style = plot.style_histogram) // Sayım işlemleri için değişkenler var bool maviSayimAktif = false var bool siyahSayimAktif = false var float sonMumHigh = na var float sonMumLow = na var int maviSayim = 1 var int siyahSayim = 1 if (vaiColor == color.blue) // İndikatör maviyken sayım işlemi if not maviSayimAktif if (maviSayim == 1 and show1) or (maviSayim == 2 and show2) or (maviSayim == 3 and show3) or (maviSayim == 4 and show4) or (maviSayim == 5 and show5) or (maviSayim == 6 and show6) or (maviSayim == 7 and show7) or (maviSayim == 8 and show8) or (maviSayim == 9 and show9) label.new(bar_index, high, text = str.tostring(maviSayim), style = label.style_label_down, color = color.green, textcolor = color.white) sonMumHigh := high maviSayim := maviSayim + 1 maviSayimAktif := true siyahSayimAktif := false // Siyah sayım biter siyahSayim := 1 // Siyah sayım sıfırlanır if maviSayimAktif and high > sonMumHigh if (maviSayim == 1 and show1) or (maviSayim == 2 and show2) or (maviSayim == 3 and show3) or (maviSayim == 4 and show4) or (maviSayim == 5 and show5) or (maviSayim == 6 and show6) or (maviSayim == 7 and show7) or (maviSayim == 8 and show8) or (maviSayim == 9 and show9) label.new(bar_index, high, text = str.tostring(maviSayim), style = label.style_label_down, color = color.green, textcolor = color.white) sonMumHigh := high maviSayim := maviSayim + 1 if maviSayim > 9 maviSayim := 1 // Sayım 9'a ulaştığında tekrar 1'e dön if (vaiColor == color.black) // İndikatör siyahken sayım işlemi if not siyahSayimAktif if (siyahSayim == 1 and show1) or (siyahSayim == 2 and show2) or (siyahSayim == 3 and show3) or (siyahSayim == 4 and show4) or (siyahSayim == 5 and show5) or (siyahSayim == 6 and show6) or (siyahSayim == 7 and show7) or (siyahSayim == 8 and show8) or (siyahSayim == 9 and show9) label.new(bar_index, low, text = str.tostring(siyahSayim), style = label.style_label_up, color = color.red, textcolor = color.white) sonMumLow := low siyahSayim := siyahSayim + 1 siyahSayimAktif := true maviSayimAktif := false // Mavi sayım biter maviSayim := 1 // Mavi sayım sıfırlanır if siyahSayimAktif and low < sonMumLow if (siyahSayim == 1 and show1) or (siyahSayim == 2 and show2) or (siyahSayim == 3 and show3) or (siyahSayim == 4 and show4) or (siyahSayim == 5 and show5) or (siyahSayim == 6 and show6) or (siyahSayim == 7 and show7) or (siyahSayim == 8 and show8) or (siyahSayim == 9 and show9) label.new(bar_index, low, text = str.tostring(siyahSayim), style = label.style_label_up, color = color.red, textcolor = color.white) sonMumLow := low siyahSayim := siyahSayim + 1 if siyahSayim > 9 siyahSayim := 1 // Sayım 9'a ulaştığında tekrar 1'e dön
Leave a Comment