TTwinCloud W-D Dual Timeframe Ichimoku Cloud

TT136 · study · 95 行 · 点赞 37 · TradingView 原页

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

Pine Script

//@version=6
indicator("TTwinCloud W-D", shorttitle="TTwinCloud W-D", overlay=true)
 
// © 2026 TT136 - TTwinCloud W/D
// Free for the TradingView community
// Elliott Wave & MSB analysis support
 
// ────── COLORS (user adjustable) ──────
colorWeeklyA = #3b82f6   // Weekly Lead A
colorWeeklyB = #c8102e   // Weekly Lead B
colorDailyA  = #3fffa2   // Daily Lead A
colorDailyB  = #ff8c38   // Daily Lead B
colorEMA1    = #ffd700   // Weekly EMA 1
colorEMA2    = #b026ff   // Weekly EMA 2
colorFillW0  = #1e90ff   // Fill Weekly 0 (A > B)
colorFillW1  = #f23645   // Fill Weekly 1 (A < B)
colorFillD0  = #3fffa2   // Fill Daily 0 (A > B)
colorFillD1  = #ff8c38   // Fill Daily 1 (A < B)
 
// ────── DISPLAY: price scale labels & status line off ──────
plotDisplay = display.all - display.price_scale - display.status_line
 
// Weekly Lead A/B: hidden by default, user can enable in Style tab
displayWeeklyLines = display.none
 
// ────── ICHIMOKU PRESET (fixed) ──────
preset = input.string("Original Japanese (9/26/52)", "Ichimoku Preset",
     options=["Original Japanese (9/26/52)", "Western (8/22/44)", "Fibonacci (8/34/55)"],
     tooltip="The classic Ichimoku values originate from the Japanese trading calendar: 9 = 1.5 weeks, 26 = 1 month, 52 = 2 months — based on the historical 6-day trading week in Japan. The Western calendar uses the 5-day week: 8 = 1.5 weeks, 22 = 1 month, 44 = 2 months. Fibonacci uses the sequence 8 / 34 / 55.")
 
tenkanPeriod  = preset == "Original Japanese (9/26/52)" ? 9  : preset == "Western (8/22/44)" ? 8  : 8
kijunPeriod   = preset == "Original Japanese (9/26/52)" ? 26 : preset == "Western (8/22/44)" ? 22 : 34
senkouBPeriod = preset == "Original Japanese (9/26/52)" ? 52 : preset == "Western (8/22/44)" ? 44 : 55
 
// ────── CLOUD OFFSET (shared, default 1) ──────
cloudOffset = input.int(1, "Cloud Offset (Periods into the Future)", minval=0, maxval=200,
     tooltip="Standard Ichimoku projects the cloud 26 periods into the future. This script defaults to 1 to keep the cloud close to price action. Increase this value to shift both clouds (Weekly and Daily) further ahead.")
 
// ────── ADJUSTABLE EMA PARAMETERS ──────
ema1_period = input.int(55, "Weekly EMA 1 (e.g. 50/55)", step=1)
ema2_period = input.int(233, "Weekly EMA 2 (e.g. 200/233)", step=1)
 
// ────── TIMEFRAME LOGIC ──────
tfSeconds  = timeframe.in_seconds(timeframe.period)
isMonthly  = timeframe.period == "1M"
isUnder1H  = tfSeconds < 60 * 60
 
showDaily  = not isMonthly      // Daily cloud hidden only on monthly chart
showWeekly = not isUnder1H      // Weekly cloud hidden below 60 minutes
 
// ═══════════════════════════════════════════════════════════════
// 1️⃣ WEEKLY BASE (1W) - fixed, realtime cloud
// ═══════════════════════════════════════════════════════════════
tenkan_w  = request.security(syminfo.tickerid, "W", (ta.highest(high, tenkanPeriod) + ta.lowest(low, tenkanPeriod)) / 2)
kijun_w   = request.security(syminfo.tickerid, "W", (ta.highest(high, kijunPeriod) + ta.lowest(low, kijunPeriod)) / 2)
senkouB_w = request.security(syminfo.tickerid, "W", (ta.highest(high, senkouBPeriod) + ta.lowest(low, senkouBPeriod)) / 2)
 
leadingA_w = request.security(syminfo.tickerid, "W", (tenkan_w + kijun_w) / 2)
leadingB_w = request.security(syminfo.tickerid, "W", senkouB_w)
 
// Weekly EMAs (adjustable, fixed to 1W)
ema1_weekly = request.security(syminfo.tickerid, "W", ta.ema(close, ema1_period))
ema2_weekly = request.security(syminfo.tickerid, "W", ta.ema(close, ema2_period))
 
// ═══════════════════════════════════════════════════════════════
// 2️⃣ DAILY BASE (1D) - fixed, realtime cloud
// ═══════════════════════════════════════════════════════════════
tenkan_d  = request.security(syminfo.tickerid, "D", (ta.highest(high, tenkanPeriod) + ta.lowest(low, tenkanPeriod)) / 2)
kijun_d   = request.security(syminfo.tickerid, "D", (ta.highest(high, kijunPeriod) + ta.lowest(low, kijunPeriod)) / 2)
senkouB_d = request.security(syminfo.tickerid, "D", (ta.highest(high, senkouBPeriod) + ta.lowest(low, senkouBPeriod)) / 2)
 
leadingA_d = request.security(syminfo.tickerid, "D", (tenkan_d + kijun_d) / 2)
leadingB_d = request.security(syminfo.tickerid, "D", senkouB_d)
 
// ═══════════════════════════════════════════════════════════════
// PLOTS - WEEKLY CLOUD
// ═══════════════════════════════════════════════════════════════
plotA_w = plot(showWeekly ? leadingA_w : na, "Weekly Lead A", colorWeeklyA, 1, offset = cloudOffset, display = displayWeeklyLines)
plotB_w = plot(showWeekly ? leadingB_w : na, "Weekly Lead B", colorWeeklyB, 1, offset = cloudOffset, display = displayWeeklyLines)
fill(plotA_w, plotB_w,
     color = leadingA_w > leadingB_w ? color.new(colorFillW0, 85) : color.new(colorFillW1, 85))
 
// ═══════════════════════════════════════════════════════════════
// PLOTS - DAILY CLOUD
// ═══════════════════════════════════════════════════════════════
plotA_d = plot(showDaily ? leadingA_d : na, "Daily Lead A", colorDailyA, 1, offset = cloudOffset, display = plotDisplay)
plotB_d = plot(showDaily ? leadingB_d : na, "Daily Lead B", colorDailyB, 1, offset = cloudOffset, display = plotDisplay)
fill(plotA_d, plotB_d,
     color = leadingA_d > leadingB_d ? color.new(colorFillD0, 90) : color.new(colorFillD1, 90))
 
// ═══════════════════════════════════════════════════════════════
// PLOTS - WEEKLY EMAS (both dotted, fixed to 1W)
// ═══════════════════════════════════════════════════════════════
plot(ema1_weekly, "EMA1 Weekly", colorEMA1, 1, plot.style_line, linestyle = plot.linestyle_dotted, display = plotDisplay)
plot(ema2_weekly, "EMA2 Weekly", colorEMA2, 1, plot.style_line, linestyle = plot.linestyle_dotted, display = plotDisplay)

← 返回列表