OPEN-SOURCE SCRIPT
james S/R Trend Pro v6

//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)
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)
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
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.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
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.