3dge Trend

Martin3dge · study · 47 行 · 点赞 2 · TradingView 原页

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

Pine Script

//@version=6
// ============================================================================
//  3dge Trend
//  EMA 100 / EMA 200 ribbon.
// ============================================================================
indicator("3dge Trend", shorttitle = "3dge Trend", overlay = true)
 
// ───────────────────────────── Inputs ─────────────────────────────
grpTF  = "Timeframe"
tfMode    = input.string("Follow Chart", "Mode", options = ["Follow Chart", "Fixed Timeframe"], group = grpTF,
     tooltip = "Follow Chart: the EMAs update automatically to whatever timeframe you open (Daily chart = Daily EMAs, Weekly chart = Weekly EMAs).\nFixed Timeframe: always shows the EMAs of the timeframe selected below, on any chart.")
tf        = input.timeframe("W", "Fixed Timeframe", group = grpTF,
     tooltip = "Only used in Fixed Timeframe mode. Use a timeframe equal to or higher than your chart.")
noRepaint = input.bool(true, "Confirmed candles only (no repaint)", group = grpTF,
     tooltip = "Fixed Timeframe mode only. ON: uses the last CLOSED higher-timeframe candle, so values never change after the fact.")
 
grpMA  = "EMAs"
src     = input.source(close, "Source", group = grpMA)
fastLen = input.int(100, "Fast EMA Length", minval = 1, group = grpMA)
slowLen = input.int(200, "Slow EMA Length", minval = 1, group = grpMA)
 
grpCol = "Colors"
fastCol    = input.color(color.new(#9AA0A6, 0), "EMA 100 Line", group = grpCol)
slowCol    = input.color(color.new(#9AA0A6, 40), "EMA 200 Line", group = grpCol)
lineWidth  = input.int(2, "Line Width", minval = 1, maxval = 4, group = grpCol)
showFill   = input.bool(true, "Show Fill Between EMAs", group = grpCol)
fillCol    = input.color(color.new(#9AA0A6, 0), "Fill Color", group = grpCol)
fillTransp = input.int(80, "Fill Transparency", minval = 0, maxval = 100, group = grpCol)
 
// ───────────────────────────── Calculations ─────────────────────────────
followChart = tfMode == "Follow Chart"
offset    = noRepaint ? 1 : 0
lookahead = noRepaint ? barmerge.lookahead_on : barmerge.lookahead_off
 
fastChart = ta.ema(src, fastLen)
slowChart = ta.ema(src, slowLen)
 
fastFixed = request.security(syminfo.tickerid, tf, ta.ema(src, fastLen)[offset], lookahead = lookahead)
slowFixed = request.security(syminfo.tickerid, tf, ta.ema(src, slowLen)[offset], lookahead = lookahead)
 
fastEMA = followChart ? fastChart : fastFixed
slowEMA = followChart ? slowChart : slowFixed
 
// ───────────────────────────── Plots ─────────────────────────────
pFast = plot(fastEMA, "EMA 100", color = fastCol, linewidth = lineWidth)
pSlow = plot(slowEMA, "EMA 200", color = slowCol, linewidth = lineWidth)
fill(pFast, pSlow, color = showFill ? color.new(fillCol, fillTransp) : na, title = "EMA Fill")

← 返回列表