SuperTrend Volume [BigBeluga]

BigBeluga · study · 56 行 · 点赞 3,259 · TradingView 原页

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

Pine Script

// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International  
// https://creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
 
//@version=6
indicator("SuperTrend Volume [BigBeluga]", overlay = true, max_lines_count = 500, max_labels_count = 500)
import TradingView/ta/9
 
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float  multip  = input.float(4, "Bands", step = 0.01)
bool   option_ = input.string("Bars", "Volume Type", ["Bars", "Area"]) == "Bars"
 
var   line1       = line(na)
label labl        = label(na)
float volume_line = float(na)
// }
 
 
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
[supertrend, direction] = ta.supertrend(multip, 25)
float distance     = ta.sma(high - low, 200)
float supertrend1  = supertrend + distance * direction 
float n_vol        = math.min(4, (volume / ta.stdev(volume, 200)))
float step         = (supertrend - supertrend1)/4
bool  trend_change = direction != direction[1]
// }
 
 
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
color trend_col    = direction < 0 ? color.lime : color.fuchsia 
color bars_col     = color.from_gradient(n_vol, 0, 4, color.new(trend_col, 60), trend_col)
 
// Volume Histogram
if bar_index % 1 == 0 and not trend_change
 
    line1 := line.new(bar_index, supertrend1 +step*n_vol, bar_index, supertrend1, width = 3, color = option_ ? bars_col : na)
 
    labl  := label.new(bar_index, line1.get_y1(), str.tostring(n_vol, "#.##"), style = label.style_label_left, color = trend_col)
 
label.delete(labl[1])
 
// Main Plot
float vol_val = trend_change ? na : (option_ ? na : line1.get_y1())
 
vol_line   = plot(vol_val, color = trend_col, style = plot.style_linebr)
super_line1= plot(trend_change ? na : supertrend1, linewidth = 2, color = trend_col, style = plot.style_linebr)
super_line = plot(trend_change ? na : supertrend, color = color.new(trend_col, 30), style = plot.style_steplinebr)
 
fill(vol_line, super_line1, vol_val, supertrend1, trend_col, color.new(trend_col, 50))
 
// Max Vol points
if n_vol == 4 
    source = direction < 0 ? high : low
    style  = direction < 0 ? label.style_label_down : label.style_label_up
    label.new(bar_index, direction < 0 ? high : low, "o", color = color.new(color.black, 100), textcolor = trend_col, style = style)
// }

← 返回列表