Tomer-Candle moves values

baumtb · study · 30 行 · 点赞 4 · 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/
// © baumtb
 
 
//@version=6
indicator("Tomer-Candle $ Change (Open to Close)", shorttitle="Candle $ Change", overlay=true, max_labels_count=500)
 
// === Settings ===
grpD = "Display"
showFlat  = input.bool(true, "Show candles with no change", group=grpD)
minMove   = input.float(0.0, "Show only moves larger than ($)", minval=0.0, step=0.05, group=grpD)
labelSize = input.string(size.small, "Text size", options=[size.auto, size.tiny, size.small, size.normal, size.large], group=grpD)
 
grpC = "Colors"
upColor   = input.color(color.new(#1b5e20, 0), "Up candle",   group=grpC)
downColor = input.color(color.new(#b71c1c, 0), "Down candle", group=grpC)
flatColor = input.color(color.new(#616161, 0), "No change",   group=grpC)
 
// === Calculation: dollar move from candle open to candle close ===
chg    = close - open
absChg = math.abs(chg)
 
show = (chg != 0 or showFlat) and absChg >= minMove
txt  = (chg > 0 ? "+" : chg < 0 ? "-" : "") + str.tostring(absChg, format.mintick)
col  = chg > 0 ? upColor : chg < 0 ? downColor : flatColor
 
// Label sits in the middle of the candle body, text only, no background
if show
    label.new(bar_index, (open + close) / 2, txt, style=label.style_none, color=color.new(color.white, 100), textcolor=col, size=labelSize)
plot(close)

← 返回列表