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)
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.