OPEN-SOURCE SCRIPT

james S/R Trend Pro v6

262
//version=6
strategy("jaems_MACD+RSI[Fixed]", shorttitle="jaems_MACD+RSI[Fixed]", overlay=false, initial_capital=10000, currency=currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05, calc_on_every_tick=false)

// =============================================================================
// 1. ์„ค์ • (Inputs)
// =============================================================================

group_macd = "๐Ÿ“Š MACD ์„ค์ •"
fastLen = input.int(12, "Fast Length", group=group_macd)
slowLen = input.int(26, "Slow Length", group=group_macd)
sigLen = input.int(9, "Signal Smoothing", group=group_macd)
src = input.source(close, "Source", group=group_macd)

group_col = "๐ŸŽจ ์‹œ๊ฐํ™” ์ƒ‰์ƒ"
col_up = input.color(color.new(#00E676, 0), "์ƒ์Šน (Neon Green)", group=group_col)
col_dn = input.color(color.new(#FF1744, 0), "ํ•˜๋ฝ (Red)", group=group_col)
col_sig = input.color(color.new(#FFEA00, 0), "Signal ๊ธฐ๋ณธ์ƒ‰", group=group_col)

// =============================================================================
// 2. ๊ณ„์‚ฐ (Calculations)
// =============================================================================

fastMA = ta.ema(src, fastLen)
slowMA = ta.ema(src, slowLen)
macd = fastMA - slowMA
signal = ta.ema(macd, sigLen)
hist = macd - signal

// ๊ต์ฐจ ํ™•์ธ (Crossovers)
bool crossUp = ta.crossover(macd, signal)
bool crossDn = ta.crossunder(macd, signal)

// ์ถ”์„ธ ์ƒํƒœ ํ™•์ธ
bool isBullish = macd >= signal

// =============================================================================
// 3. ์ „๋žต ์‹คํ–‰ (Execution)
// =============================================================================

if crossUp
strategy.entry("Long", strategy.long)

if crossDn
strategy.entry("Short", strategy.short)

// =============================================================================
// 4. ์‹œ๊ฐํ™” (Visualization) - ์ˆ˜์ •๋œ ๋ถ€๋ถ„
// =============================================================================

// 4.1 MACD ๋ผ์ธ ์ƒ‰์ƒ ๋™์  ๋ณ€๊ฒฝ
color macdDynamicColor = isBullish ? col_up : col_dn

// 4.2 ๋ผ์ธ ๊ทธ๋ฆฌ๊ธฐ
plot(macd, title="MACD Line", color=macdDynamicColor, linewidth=2)
plot(signal, title="Signal Line", color=col_sig, linewidth=1)

// 4.3 ๊ต์ฐจ์  ๋„ํŠธ (Thick Dots) - ๊ด„ํ˜ธ ์˜ค๋ฅ˜ ๋ฐฉ์ง€๋ฅผ ์œ„ํ•ด ๋ช…์‹œ์  ๋ณ€์ˆ˜ ํ• ๋‹น
float dotLevelUp = crossUp ? signal : na
float dotLevelDn = crossDn ? signal : na

plot(dotLevelUp, title="Golden Cross Dot", style=plot.style_circles, color=col_up, linewidth=5)
plot(dotLevelDn, title="Dead Cross Dot", style=plot.style_circles, color=col_dn, linewidth=5)

// 4.4 ํžˆ์Šคํ† ๊ทธ๋žจ ์ƒ‰์ƒ (์˜ค๋ฅ˜ ์ˆ˜์ •: ์ค‘์ฒฉ ์‚ผํ•ญ์—ฐ์‚ฐ์ž ์ œ๊ฑฐ -> if-else ๋ณ€ํ™˜)
color histColor = na
if isBullish
// ์ƒ์Šน ์ถ”์„ธ์ผ ๋•Œ: ํžˆ์Šคํ† ๊ทธ๋žจ์ด ์ง์ „๋ณด๋‹ค ์ปค์ง€๋ฉด ์ง„ํ•œ์ƒ‰, ์ž‘์•„์ง€๋ฉด ์—ฐํ•œ์ƒ‰
if hist[1] < hist
histColor := col_up
else
histColor := color.new(col_up, 50)
else
// ํ•˜๋ฝ ์ถ”์„ธ์ผ ๋•Œ: ํžˆ์Šคํ† ๊ทธ๋žจ์ด ์ง์ „๋ณด๋‹ค ์ปค์ง€๋ฉด(๋œ ์Œ์ˆ˜๋ฉด) ์—ฐํ•œ์ƒ‰, ์ž‘์•„์ง€๋ฉด ์ง„ํ•œ์ƒ‰
if hist[1] < hist
histColor := color.new(col_dn, 50)
else
histColor := col_dn

plot(hist, title="Histogram", style=plot.style_columns, color=histColor)

// 4.5 ๊ธฐ์ค€์„ 
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.