SMT Scalping PRO (NQ vs ES)

GatisA · study · 73 行 · 点赞 1,690 · TradingView 原页

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

Pine Script

//@version=5
indicator("SMT Scalping PRO (NQ vs ES)", overlay=true, max_labels_count=500)
 
// === INPUTS ===
symbol2 = input.symbol("CME_MINI:ES1!", "Comparison Symbol")
swingLen = input.int(3, "Swing Sensitivity (Lower = Faster)", minval=1, maxval=10)
showLabels = input.bool(true, "Show SMT Labels")
alertsOn = input.bool(true, "Enable Alerts")
 
// === COLOR INPUTS ===
bullBgColor = input.color(color.new(color.lime, 0), "Bullish Label Background")
bearBgColor = input.color(color.new(color.red, 0), "Bearish Label Background")
bullTextColor = input.color(color.white, "Bullish Text Color")
bearTextColor = input.color(color.white, "Bearish Text Color")
 
// === SIZE INPUT ===
labelSizeInput = input.string("Small", "Label Size", options=["Small", "Normal", "Large", "Huge"])
 
// === MAP SIZE ===
labelSize =
     labelSizeInput == "Small"  ? size.small  :
     labelSizeInput == "Large"  ? size.large  :
     labelSizeInput == "Huge"   ? size.huge   :
                                  size.normal
 
// === DATA ===
price1 = open
price2 = request.security(symbol2, timeframe.period, open)
 
// === SWINGS ===
h1 = ta.pivothigh(price1, swingLen, swingLen)
l1 = ta.pivotlow(price1, swingLen, swingLen)
 
h2 = ta.pivothigh(price2, swingLen, swingLen)
l2 = ta.pivotlow(price2, swingLen, swingLen)
 
// === STORE LAST SWINGS ===
var float lastH1 = na
var float lastH2 = na
var float lastL1 = na
var float lastL2 = na
 
if not na(h1)
    lastH1 := h1
if not na(h2)
    lastH2 := h2
if not na(l1)
    lastL1 := l1
if not na(l2)
    lastL2 := l2
 
// === SMT LOGIC ===
bearSMT = not na(h1) and lastH1 > lastH1[1] and lastH2 <= lastH2[1]
bullSMT = not na(l1) and lastL1 < lastL1[1] and lastL2 >= lastL2[1]
 
// === PLOT ===
if showLabels and bearSMT
    label.new(bar_index, high, "SMT",
      style=label.style_label_down,
      color=bearBgColor,
      textcolor=bearTextColor,
      size=labelSize)
 
if showLabels and bullSMT
    label.new(bar_index, low, "SMT",
      style=label.style_label_up,
      color=bullBgColor,
      textcolor=bullTextColor,
      size=labelSize)
 
// === ALERTS ===
alertcondition(bearSMT and alertsOn, "Bearish SMT", "SMT SHORT on {{ticker}}")
alertcondition(bullSMT and alertsOn, "Bullish SMT", "SMT LONG on {{ticker}}")

← 返回列表