Traivend: CVD Line

Dominik_Traivend · study · 49 行 · 点赞 5 · TradingView 原页

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

Pine Script

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TRAIVEND
 
//@version=6
// Kein shorttitle — dadurch zeigt TradingView den vollen Titel an (erlaubt wären nur 10 Zeichen).
indicator("TRAIVEND: CVD Line", format = format.volume)
 
import TradingView/ta/10 as tvta
 
// ════════════════════════════════════════════════════════════════
//  WAS DER INDIKATOR ZEIGT
// ════════════════════════════════════════════════════════════════
//  Den CVD (Cumulative Volume Delta) als Linie — gleiche Rechnung wie der
//  eingebaute TradingView-Indikator „Cumulative Volume Delta“ (Einstellung
//  „Data aggregation“ = Time), der ihn nur als Kerzen zeichnet.
//
//  Delta  = Volumen der Market-Käufe minus Market-Verkäufe je Kerze,
//           geschätzt aus Kerzen eines kleineren Timeframes:
//           steigende Kerze = Kauf, fallende = Verkauf.
//  CVD    = das Delta Kerze für Kerze zusammengezählt; beginnt mit jedem
//           neuen Ankerzeitraum (Standard: jeden Tag) wieder bei null.
//  Linie  = der CVD-Stand am Ende jeder Kerze (= Schlusswert der CVD-Kerze).
 
// ════════════════════════════════════════════════════════════════
//  EINSTELLUNGEN
// ════════════════════════════════════════════════════════════════
 
anchorInput  = input.timeframe("1D", "Ankerzeitraum")
customInput  = input.bool(false, "Eigenen Timeframe nutzen")
lowerTfInput = input.timeframe("1", "Timeframe")
lineColor    = input.color(#4EC82E, "Linie", inline = "l")
lineWidth    = input.int(2, "", minval = 1, maxval = 5, inline = "l")
 
// Kleinerer Timeframe wie beim eingebauten CVD
lowerTimeframe = switch
    customInput          => lowerTfInput
    timeframe.isseconds  => "1S"
    timeframe.isintraday => "1"
    timeframe.isdaily    => "5"
    => "60"
 
// ════════════════════════════════════════════════════════════════
//  RECHNUNG
// ════════════════════════════════════════════════════════════════
 
[openVolume, maxVolume, minVolume, lastVolume] = tvta.requestVolumeDelta(lowerTimeframe, anchorInput)
 
hline(0, "Nulllinie", color = color.new(color.gray, 50), linestyle = hline.style_dashed)
plot(lastVolume, "CVD", color = lineColor, linewidth = lineWidth)

← 返回列表