MHIDa Dead-Ends Reference

MHIDa · study · 145 行 · 点赞 1 · TradingView 原页

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

Pine Script

//@version=6
// =============================================================================
// MHIDa Dead-Ends Reference
// A context tool to help you evaluate what you see - not a signal, not advice,
// not a winner on its own. You always decide.
// =============================================================================
//
// WHAT IT IS (rare: a tool that tells you what NOT to do):
//   An EDUCATIONAL "anti-pattern" tool. It highlights on the chart two classic
//   setups that are widely treated as edges but tend to be traps in isolation.
//   It is NOT here to buy/sell: it is here to TEACH the patterns you should NOT
//   trust on their own, so that when you spot them you understand why they fool
//   people.
//
// WHY THESE ARE "DEAD ENDS":
//
//   [A] NAKED MEAN-DISTANCE DIP-BUY:
//       "price far below the moving average -> buy" looks magical on its own,
//       but in a trending market the apparent gain is mostly the trend's pull.
//       Strip the bull phase away (e.g. bearish years) and the supposed edge
//       tends to vanish. Naked = an artifact of the trend, not a real edge.
//       Honest note: a mean-distance idea can have value, but typically only
//       AFTER a strong trigger first (a capitulation / climax event). The naked
//       dip, with no such trigger, is the trap.
//
//   [B] NAKED SHORT-FADE AT THE TOP:
//       "price stretched far up / RSI hot -> short" is the classic contrarian
//       trap. In a strongly trending up market, every blind top-short tends to
//       get run over by the prevailing current.
//       Honest note: this does NOT mean "shorting is always dead". A top-fade
//       can sometimes work, but typically only with a calm-crest filter plus an
//       asymmetric trailing EXIT - i.e. the edge lives in the EXIT, not in the
//       entry. The NAKED top-short (what this tool highlights) stays a dead end.
//
// HOW TO USE IT (it is a REMINDER, not a signal):
//   - When you see a "DIP TRAP?" marker -> it is NOT a buy. It is a reminder:
//     "this is the naked dip pattern; ask yourself whether there is a REAL
//      trigger first (a climax / capitulation), or it is just mean-distance".
//   - When you see a "SHORT TRAP?" marker -> it is NOT a sell. It is a reminder:
//     "this is the naked top-short that tends to drown in a strong uptrend".
//   The markers say "CAREFUL, this is where people historically get burned",
//   not "act here".
//
// LIMITS, STATED CLEARLY:
//   - No performance numbers here: this tool does not tie any backtest result to
//     THIS chart, so it does not invent any. The "dead end" verdicts are general
//     observations, not a claim about this specific symbol/timeframe.
//   - It is not a signal and not advice. It is not a winner on its own (by
//     definition: it highlights LOSING patterns). It exists to help you avoid
//     repeating common mistakes.
//   - The defaults are an educational starting point, NOT a recommended config.
//   - No lookahead: everything is computed on closed bars.
// =============================================================================
 
indicator("MHIDa Dead-Ends Reference", shorttitle="DeadEnds", overlay=true,
     max_labels_count=500)
 
// -----------------------------------------------------------------------------
// INPUT - thresholds as a STARTING POINT (defaults are only a starting point)
// -----------------------------------------------------------------------------
grpA = "Trap A - naked DIP-BUY (distance below the moving average)"
showDip   = input.bool(true, "Highlight the naked-DIP trap", group=grpA)
emaLen    = input.int(20,   "Reference moving average (EMA)", minval=2, group=grpA)
dipPct    = input.float(8.0,"Distance % below the average for a 'dip'", minval=0.1, step=0.1, group=grpA,
     tooltip="How far below the average (in %) before calling it a dip. On its own = a trap.")
needGreen = input.bool(true,"Require a green candle (like the naked setup)", group=grpA)
 
grpB = "Trap B - SHORT-FADE at the top (naked top-short)"
showShort = input.bool(true, "Highlight the naked top-SHORT trap", group=grpB)
rsiLen    = input.int(14,   "RSI length", minval=2, group=grpB)
rsiHot    = input.float(70.0,"RSI 'hot' level above which the top-short fires", minval=50, maxval=99, step=1, group=grpB)
stretchUp = input.float(8.0,"Stretch % ABOVE the average (top)", minval=0.1, step=0.1, group=grpB,
     tooltip="How far above the average (in %) before calling it a 'stretched top'. Shorting here = a trap.")
needRed   = input.bool(true,"Require a red pullback candle (close<close[1])", group=grpB)
 
grpV = "View"
showWhy   = input.bool(true,"Show TRAP labels (why)", group=grpV)
showNote  = input.bool(true,"Show honest note in the top-right corner", group=grpV)
 
// -----------------------------------------------------------------------------
// BASE CALCULATIONS (no lookahead: closed bars are used)
// -----------------------------------------------------------------------------
emaMid = ta.ema(close, emaLen)
nDown  = dipPct   / 100.0
nUp    = stretchUp / 100.0
rsi    = ta.rsi(close, rsiLen)
 
// --- Trap A: NAKED DIP (mean-distance, like the dead-end setup) ---
//   same shape as the naked dip: close[1] far BELOW the average, then green.
stretchedDown = close[1] < emaMid[1] * (1.0 - nDown)
greenBack     = close > close[1]
dipTrap = showDip and stretchedDown and (needGreen ? greenBack : true)
 
// --- Trap B: NAKED TOP-SHORT (top-fade, like the dead-end setup) ---
//   top stretched ABOVE the average + hot RSI, then a red pullback candle.
stretchedUp = close[1] > emaMid[1] * (1.0 + nUp)
hotRsi      = rsi[1] >= rsiHot
redBack     = close < close[1]
shortTrap = showShort and stretchedUp and hotRsi and (needRed ? redBack : true)
 
// -----------------------------------------------------------------------------
// DRAWING - "caution" tones, NOT "buy/sell" tones
// -----------------------------------------------------------------------------
plot(emaMid, "EMA (average)", color=color.new(color.gray, 30), linewidth=1)
 
// Light ALERT backgrounds (amber = caution, not action)
bgcolor(dipTrap   ? color.new(color.orange, 85) : na, title="DIP trap background")
bgcolor(shortTrap ? color.new(color.purple, 85) : na, title="SHORT trap background")
 
// Marker: exclamation mark, NOT an entry arrow (to avoid suggesting action)
plotshape(dipTrap and chart.is_standard, title="Naked DIP trap", style=shape.labeldown,
     location=location.belowbar, color=color.new(color.orange, 10),
     text="!", textcolor=color.white, size=size.tiny)
 
plotshape(shortTrap and chart.is_standard, title="Top SHORT trap", style=shape.labelup,
     location=location.abovebar, color=color.new(color.purple, 10),
     text="!", textcolor=color.white, size=size.tiny)
 
// Explanatory labels (the "why" of the trap)
if showWhy and dipTrap and chart.is_standard
    label.new(bar_index, low,
         "DIP TRAP?\nnaked dip = trend artifact\nfades when the trend is gone\nyou need a REAL trigger first",
         style=label.style_label_up, color=color.new(color.orange, 15),
         textcolor=color.white, size=size.small)
 
if showWhy and shortTrap and chart.is_standard
    label.new(bar_index, high,
         "SHORT TRAP?\nnaked top-short = dead end\ntends to drown in an uptrend",
         style=label.style_label_down, color=color.new(color.purple, 15),
         textcolor=color.white, size=size.small)
 
// Fixed honest note in the top-right corner
var table note = na
if showNote and barstate.islast
    note := table.new(position.top_right, 1, 1, border_width=1)
    table.cell(note, 0, 0,
         "MHIDa Dead-Ends Reference\nHighlights LOSING setups (naked dip / naked top-short).\nNOT a signal: a reminder of what NOT to trust.\nYou always decide.",
         text_color=color.white, text_size=size.tiny,
         bgcolor=color.new(color.gray, 80), text_halign=text.align_left)
 
// Optional alerts: they warn about the TRAP, not about an action
alertcondition(dipTrap, title="MHIDa: a naked DIP spotted (historical trap)",
     message="MHIDa Dead-Ends: naked mean-distance dip-buy -> a setup to be wary of (trend artifact). NOT a signal and NOT advice.")
alertcondition(shortTrap, title="MHIDa: a top SHORT spotted (historical trap)",
     message="MHIDa Dead-Ends: naked top-fade short -> a dead-end setup (tends to drown in an uptrend). NOT a signal and NOT advice.")

← 返回列表