برای نمایش اندیکاتور ایچیموکو روی نمودار قیمت در TradingView، از کد زیر استفاده کنید. این نسخه بهینهشده تمام اجزای ایچیموکو را به صورت واضح روی چارت نمایش میدهد:
کد نهایی ایچیموکو برای TradingView (نسخه روی نمودار):
//@version=5
indicator('Ichimoku Cloud [On Chart]', shorttitle='Ichimoku', overlay=true, max_lines_count=500)
// ———————— Inputs ————————
tenkan_len = input(9, 'Tenkan Sen Length')
kijun_len = input(26, 'Kijun Sen Length')
senkou_len = input(52, 'Senkou Span B Length')
displacement = input(26, 'Displacement')
// ———————— Calculations ————————
tenkan_sen = (ta.highest(high, tenkan_len) + ta.lowest(low, tenkan_len)) / 2
kijun_sen = (ta.highest(high, kijun_len) + ta.lowest(low, kijun_len)) / 2
senkou_A = (tenkan_sen + kijun_sen) / 2
senkou_B = (ta.highest(high, senkou_len) + ta.lowest(low, senkou_len)) / 2
// ———————— Cloud Visualization ————————
// Future cloud (shifted forward)
senkou_A_shifted = senkou_A[displacement]
senkou_B_shifted = senkou_B[displacement]
cloud_top = math.max(senkou_A_shifted, senkou_B_shifted)
cloud_bot = math.min(senkou_A_shifted, senkou_B_shifted)
// Cloud color conditions
bullish_cloud = senkou_A_shifted > senkou_B_shifted
bearish_cloud = senkou_A_shifted < senkou_B_shifted
// ———————— Plots ————————
// 1. Lines
plot(tenkan_sen, 'Tenkan Sen', #2962FF, 2)
plot(kijun_sen, 'Kijun Sen', #B71C1C, 2)
plot(close, 'Chikou Span', #7B1FA2, 2, offset = -displacement)
// 2. Cloud (with enhanced visibility)
fill(plot(senkou_A_shifted, 'Senkou A', #26A69A, 1, display=display.none),
plot(senkou_B_shifted, 'Senkou B', #EF5350, 1, display=display.none),
color = bullish_cloud ? color.new(#26A69A, 85) : color.new(#EF5350, 85),
title = 'Kumo Cloud')
// 3. Cloud Borders (dashed lines)
plot(senkou_A_shifted, 'Senkou A Border', bullish_cloud ? #26A69A : #EF5350, 1, style=plot.style_linebr)
plot(senkou_B_shifted, 'Senkou B Border', bullish_cloud ? #26A69A : #EF5350, 1, style=plot.style_linebr)
// ———————— Trading Signals ————————
// Entry Conditions
longCondition = ta.crossover(tenkan_sen, kijun_sen) and
close > cloud_top and
close > kijun_sen and
bullish_cloud
shortCondition = ta.crossunder(tenkan_sen, kijun_sen) and
close < cloud_bot and
close < kijun_sen and
bearish_cloud
// Plot Signals
plotshape(longCondition, 'Buy', shape.triangleup, location.belowbar, #00C853, size=size.small)
plotshape(shortCondition, 'Sell', shape.triangledown, location.abovebar, #FF5252, size=size.small)
// ———————— Alerts ————————
alertcondition(longCondition, 'Ichimoku Buy Signal', 'Tenkan crossed Kijun UP + Bullish Cloud')
alertcondition(shortCondition, 'Ichimoku Sell Signal', 'Tenkan crossed Kijun DOWN + Bearish Cloud')
ویژگیهای کلیدی این نسخه:
-
نمایش واضح روی نمودار قیمت:
- خطوط تنکان (آبی) و کیجون (قرمز) با ضخامت مناسب