本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
// =============================================================================
// MHIDa Crest Volume-Climax Detector - a tool to support your
// own reading of what you see, not a signal nor advice, not a winner on its
// own. You always decide.
// =============================================================================
//
// WHAT IT DOES
// Measures the "volume climax" at a top: how far the bar's volume (or the
// peak volume over the last few bars) sits above its recent average. A
// volume climax at a top often accompanies a fading of momentum, but it is
// a CLUE to be put in context, not a proof.
//
// THE IDEA
// Two causal measures (using past bars only):
// vol_ratio = volume[i] / mean(volume[i-20:i])
// vol_climax5 = max(volume[i-5:i]) / mean(volume[i-20:i])
// Default average lookback = 20 bars. The "climax" threshold is an
// adjustable starting point, not a proven winning value.
//
// HONESTY (please read)
// - This is a DETECTOR with FALSE POSITIVES: many volume spikes are NOT
// tops (real breakouts, news, session open, illiquidity). It will fire
// where there is nothing to do.
// - On its own it is NOT enough. Use it as SUPPORT to what you see on the
// chart (structure, levels, context).
// - No performance promises. No win-rate numbers in here: we don't invent
// figures the tool cannot honestly support.
// - No look-ahead: it uses only closed bars up to the current one.
//
// SUGGESTED USE
// Look at the chart. When you spot a possible top, check whether a volume
// climax is firing here: it is one MORE element in your judgment, never the
// judgment itself. The decision stays yours.
// =============================================================================
indicator("MHIDa Crest Volume-Climax Detector", shorttitle = "VolClimax", overlay = false)
// ------------------------------- Input (default = starting point) ------------
lenAvg = input.int(20, "Volume average lookback (bars)", minval = 2,
tooltip = "Average volume the climax is measured against. Default 20.")
climaxMult = input.float(2.0, "Climax threshold (volume / average)", minval = 1.0, step = 0.1,
tooltip = "A starting point, not a proven winning value. Above this threshold = climax. Raise it to be more selective.")
peakLen = input.int(5, "Recent peak window (bars)", minval = 1,
tooltip = "For vol_climax5: takes the maximum volume over the last N bars (default 5).")
showPeak = input.bool(true, "Also show climax on recent peak (vol_climax5)")
// ------------------------------- Calculations (causal) -----------------------
// Average volume over the last lenAvg bars, excluding the current bar
// (consistent with mean(volume[i-20:i]): bars i-20..i-1).
volMeanPrev = ta.sma(volume[1], lenAvg)
// Current bar ratio vs recent average
volRatio = na(volMeanPrev) or volMeanPrev <= 0 ? na : volume / volMeanPrev
// Climax on the recent peak: max volume over the last peakLen bars / recent average
volPeak = ta.highest(volume, peakLen)
volClimax5 = na(volMeanPrev) or volMeanPrev <= 0 ? na : volPeak / volMeanPrev
// "Climax on" states
isClimax = not na(volRatio) and volRatio >= climaxMult
isClimaxPeak = not na(volClimax5) and volClimax5 >= climaxMult
// ------------------------------- Plot ----------------------------------------
colRatio = isClimax ? color.new(color.orange, 0) : color.new(color.gray, 40)
plot(volRatio, "Volume / average", color = colRatio, style = plot.style_columns)
plot(showPeak ? volClimax5 : na, "Peak / average (vol_climax5)",
color = color.new(color.teal, 30), linewidth = 1, style = plot.style_line)
hline(climaxMult, "Climax threshold", color = color.new(color.red, 0),
linestyle = hline.style_dashed)
hline(1.0, "Volume = average", color = color.new(color.gray, 60),
linestyle = hline.style_dotted)
// Marker below the threshold when the climax fires on the current bar
plotshape(isClimax and chart.is_standard, "Volume climax (clue, not a signal)", shape.triangleup, location.bottom,
color = color.new(color.orange, 0), size = size.tiny)
// ------------------------------- On-screen note ------------------------------
var table note = table.new(position.top_right, 1, 1, border_width = 1)
if barstate.islast
txt = "MHIDa Volume-Climax\nSUPPORT, not a signal\nhas false positives - you decide"
table.cell(note, 0, 0, txt, text_size = size.small,
text_color = color.white, bgcolor = color.new(color.black, 20))
// Optional alert (still a clue to put in context, never an order)
alertcondition(isClimax, "MHIDa Volume-Climax on",
"Volume climax on the current bar. A clue to put in context on the chart, not a signal.")