TapeVitals - Float, RVOL & RSI [MohaveTrader]

MohaveTrader · study · 172 行 · 点赞 7 · TradingView 原页

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

Pine Script

// © MohaveTrader
// TapeVitals - Float, RVOL & RSI [MohaveTrader] (TapeVitals)
// Version History
// v1.0 — October 2026
// • Five values: Float, Chg%, Vol, RVOL, RSI, in the status line and in an optional table
//   with headers (same order, same colors)
// • Float: TradingView's current float first, report figures only as a fallback; bright
//   green at or under the Low Float level (default 20M)
// • Chg%: change from the prior day's close
// • Vol: volume traded so far today on the chart's own bars (premarket included when the
//   chart shows extended hours)
// • RVOL: time of day aware. Volume so far today against the average volume by this same
//   time over the prior days (default 10), so it reads fairly from the open, not only at the
//   close. On daily and higher charts it is the bar's volume against the prior bars' average
// • RSI(14) on the chart timeframe, with a neutral band around 50
// • Color rule: bright green means favorable for momentum, red means a down move or weak RSI,
//   gray or silver means quiet or neutral
// • Alerts: RVOL In Play and RVOL Strong, using the RVOL In Play At and RVOL Strong At levels.
//   Each fires at bar close, at most once per trading day, once the day's volume reaches Alert
//   Min Volume (default 50000 shares, 0 turns the check off)
//
// Status line order: Float, Chg%, Vol, RVOL, RSI. The table shows the same values with headers.
// RVOL matches each day by clock minute, so sessions that cross midnight (futures) compare
// like with like. Float is for stocks and ETFs.
 
//@version=6
indicator("TapeVitals - Float, RVOL & RSI [MohaveTrader]", "TapeVitals", overlay = true)
 
grpS = "01. Levels"
i_lowF    = input.float(20, "Low Float (M shares)", minval = 0, step = 1, group = grpS, display = display.none, tooltip = "Float at or under this many million shares shows in the Good color.\nDefault: 20.")
i_rvDays  = input.int(10, "RVOL Days", minval = 1, maxval = 30, group = grpS, display = display.none, tooltip = "Prior days averaged for RVOL.\nDefault: 10.")
i_rvWhite = input.float(1.5, "RVOL Active At", minval = 0, step = 0.1, group = grpS, display = display.none, tooltip = "RVOL below this shows gray (quiet). From here it shows white.\nDefault: 1.5.")
i_rvAmber = input.float(2.0, "RVOL In Play At", minval = 0, step = 0.1, group = grpS, display = display.none, tooltip = "RVOL from here shows amber.\nDefault: 2.")
i_rvGreen = input.float(5.0, "RVOL Strong At", minval = 0, step = 0.5, group = grpS, display = display.none, tooltip = "RVOL from here shows the Good color. Small cap momentum traders often use 5; large caps and ETFs may want it lower.\nDefault: 5.")
i_alertMin = input.float(50000, "Alert Min Volume", minval = 0, step = 1000, group = grpS, display = display.none, tooltip = "The day's volume must reach this many shares before either RVOL alert can fire, so a few early premarket prints can't trigger them. Affects the alerts only, not the displayed values or colors. 0 turns the check off.\nDefault: 50000.")
i_rsiLen  = input.int(14, "RSI Length", minval = 2, group = grpS, display = display.none, tooltip = "Default: 14.")
i_rsiHi   = input.float(55, "RSI Strong Above", minval = 50, maxval = 100, group = grpS, display = display.none, tooltip = "RSI above this shows green.\nDefault: 55.")
i_rsiLo   = input.float(45, "RSI Weak Below", minval = 0, maxval = 50, group = grpS, display = display.none, tooltip = "RSI below this shows red. Between the two it shows silver.\nDefault: 45.")
 
grpT = "02. Table"
i_table = input.bool(true, "Show Table", group = grpT, display = display.none, tooltip = "Table with headers for the same five values. The status line values stay on either way.\nDefault: On.")
i_tPos  = input.string("Top Center", "Table Position", options = ["Top Left", "Top Center", "Top Right", "Bottom Left", "Bottom Center", "Bottom Right"], group = grpT, display = display.none, tooltip = "Default: Top Center.")
i_tSize = input.string("Normal", "Table Text Size", options = ["Tiny", "Small", "Normal", "Large"], group = grpT, display = display.none, tooltip = "Default: Normal.")
grpC = "03. Colors"
c_good   = input.color(#00ff00, "Good / Up", group = grpC, display = display.none)
c_down   = input.color(#f23645, "Down", group = grpC, display = display.none)
c_plain  = input.color(#ffffff, "Plain", group = grpC, display = display.none)
c_quiet  = input.color(#787b86, "Quiet", group = grpC, display = display.none)
c_amber  = input.color(#ffb74d, "In Play", group = grpC, display = display.none)
c_neut   = input.color(#c0c0c0, "Neutral / Headers", group = grpC, display = display.none)
 
f_kmb(float v) =>
    na(v) ? "--" : v >= 1e9 ? str.tostring(v / 1e9, "#.##") + "B" : v >= 1e6 ? str.tostring(v / 1e6, "#.##") + "M" : v >= 1e3 ? str.tostring(v / 1e3, "#.##") + "K" : str.tostring(v, "#")
 
f_pos(string s) =>
    switch s
        "Top Left"      => position.top_left
        "Top Center"    => position.top_center
        "Top Right"     => position.top_right
        "Bottom Center" => position.bottom_center
        "Bottom Right"  => position.bottom_right
        => position.bottom_left
 
f_size(string s) =>
    switch s
        "Tiny"  => size.tiny
        "Small" => size.small
        "Large" => size.large
        => size.normal
 
// Float: TradingView's current float first, report figures only as a fallback
floatFQ  = request.financial(syminfo.tickerid, "FLOAT_SHARES_OUTSTANDING", "FQ", ignore_invalid_symbol = true)
floatFY  = request.financial(syminfo.tickerid, "FLOAT_SHARES_OUTSTANDING", "FY", ignore_invalid_symbol = true)
floatNow = syminfo.shares_outstanding_float
floatSh  = not na(floatNow) and floatNow > 0 ? floatNow : not na(floatFQ) and floatFQ > 0 ? floatFQ : not na(floatFY) and floatFY > 0 ? floatFY : na
floatCol = not na(floatSh) and floatSh <= i_lowF * 1e6 ? c_good : c_plain
 
// Chg%: from the prior day's close
prevClose = request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
chgPct    = prevClose > 0 ? (close - prevClose) / prevClose * 100 : na
chgCol    = na(chgPct) ? c_plain : chgPct >= 0 ? c_good : c_down
 
// Vol: volume so far today on the chart's own bars
intraday = timeframe.isintraday
newDay   = timeframe.change("D")
var float dayVol = 0.0
dayVol := newDay ? nz(volume) : dayVol + nz(volume)
volNow  = intraday ? dayVol : volume
 
// RVOL, time of day aware. Each finished day's running volume is kept by minute of the day
// (exchange time), and today's running volume is compared with the average of those days at
// the same minute. The first, partial day on the chart is not kept.
var matrix<float> rvHist = matrix.new<float>()
var array<float>  rvDay  = array.new<float>(1440, na)
var bool rvFullDay = false
tod = hour(time, syminfo.timezone) * 60 + minute(time, syminfo.timezone)
if intraday and newDay
    if rvFullDay
        float last = 0.0
        for i = 0 to 1439
            float v = array.get(rvDay, i)
            if na(v)
                array.set(rvDay, i, last)
            else
                last := v
        matrix.add_row(rvHist, matrix.rows(rvHist), array.copy(rvDay))
        if matrix.rows(rvHist) > i_rvDays
            matrix.remove_row(rvHist, 0)
    array.fill(rvDay, na)
    rvFullDay := true
if intraday
    array.set(rvDay, tod, dayVol)
 
float rvAvg = na
int rvRows = matrix.rows(rvHist)
if intraday and rvRows > 0
    float s = 0.0
    for r = 0 to rvRows - 1
        s += matrix.get(rvHist, r, tod)
    rvAvg := s / rvRows
avgDailyVol = ta.sma(volume, i_rvDays)[1]
rvol    = intraday ? (rvAvg > 0 ? dayVol / rvAvg : na) : (avgDailyVol > 0 ? volume / avgDailyVol : na)
rvolCol = na(rvol) ? c_quiet : rvol >= i_rvGreen ? c_good : rvol >= i_rvAmber ? c_amber : rvol >= i_rvWhite ? c_plain : c_quiet
 
// Alerts: each fires at bar close the first time RVOL is at or above its level on a trading day,
// once the day's volume reaches Alert Min Volume. They reset at the same day boundary as Vol and
// RVOL, and each is independent, so one bar can fire both.
var bool playFired   = false
var bool strongFired = false
if newDay
    playFired   := false
    strongFired := false
alertVolOK = i_alertMin <= 0 or volNow >= i_alertMin
aPlay   = barstate.isconfirmed and alertVolOK and not na(rvol) and rvol >= i_rvAmber and not playFired
aStrong = barstate.isconfirmed and alertVolOK and not na(rvol) and rvol >= i_rvGreen and not strongFired
if aPlay
    playFired := true
if aStrong
    strongFired := true
alertcondition(aPlay, "RVOL In Play", "{{ticker}} TapeVitals: RVOL In Play, {{plot(\"RVOL\")}}x")
alertcondition(aStrong, "RVOL Strong", "{{ticker}} TapeVitals: RVOL Strong, {{plot(\"RVOL\")}}x")
 
// RSI on the chart timeframe
rsi    = ta.rsi(close, i_rsiLen)
rsiCol = na(rsi) ? c_neut : rsi > i_rsiHi ? c_good : rsi < i_rsiLo ? c_down : c_neut
 
// Status line values (also in the Data Window with their names)
plot(floatSh, "Float", color = floatCol, display = display.status_line + display.data_window, format = format.volume)
plot(chgPct, "Chg%", color = chgCol, display = display.status_line + display.data_window, format = format.percent, precision = 2)
plot(volNow, "Vol", color = c_plain, display = display.status_line + display.data_window, format = format.volume)
plot(rvol, "RVOL", color = rvolCol, display = display.status_line + display.data_window, format = format.price, precision = 2)
plot(rsi, "RSI", color = rsiCol, display = display.status_line + display.data_window, format = format.price, precision = 1)
 
// Table: 5 columns, headers over values, silver frame, faint cell lines
var table tb = na
if barstate.islast
    if not na(tb)
        table.delete(tb)
        tb := na
    if i_table
        ts = f_size(i_tSize)
        tb := table.new(f_pos(i_tPos), 5, 2, bgcolor = color.new(color.black, 70), frame_color = color.silver, frame_width = 2, border_color = color.new(color.gray, 70), border_width = 1)
        table.cell(tb, 0, 0, "Float", text_color = c_neut, text_size = ts)
        table.cell(tb, 1, 0, "Chg%", text_color = c_neut, text_size = ts)
        table.cell(tb, 2, 0, "Vol", text_color = c_neut, text_size = ts)
        table.cell(tb, 3, 0, "RVOL", text_color = c_neut, text_size = ts)
        table.cell(tb, 4, 0, "RSI", text_color = c_neut, text_size = ts)
        table.cell(tb, 0, 1, na(floatSh) ? "N/A" : f_kmb(floatSh), text_color = floatCol, text_size = ts)
        table.cell(tb, 1, 1, na(chgPct) ? "--" : str.tostring(chgPct, "0.00") + "%", text_color = chgCol, text_size = ts)
        table.cell(tb, 2, 1, f_kmb(volNow), text_color = c_plain, text_size = ts)
        table.cell(tb, 3, 1, na(rvol) ? "--" : str.tostring(rvol, "0.00") + "x", text_color = rvolCol, text_size = ts)
        table.cell(tb, 4, 1, na(rsi) ? "--" : str.tostring(rsi, "0.0"), text_color = rsiCol, text_size = ts)

← 返回列表