์œ„์™€ ๋น„์Šทํ•œ ํŒจํ„ด์„ ์ฐพ์•„ ๋กฑ์ˆ ํ‘œ์‹œํ•ด์คŒ


๊ธฐ๋ณธ์€ 50 ์ดํ‰์„  ์œ„์—์„œ๋Š” ๋กฑ ๋ฐ‘์—์„  ์ˆ๋งŒ ํ‘œ์‹œ ๋˜๋„๋ก ํ•จ


์ดํ‰์„  ๋ณ€๊ฒฝ๊ฐ€๋Šฅํ•จ


ํฐ ํƒ€์ž„ํ”„๋ ˆ์ž„์—์„œ ๋” ์œ ๋ฆฌํ•œ๋“ฏ


pine์—๋””ํ„ฐ์— ๋ถ™์—ฌ ๋„ฃ๊ธฐํ•ด์„œ ์“ฐ์…ˆ




//@version=5

strategy("Candle Pattern Strategy - DC Style", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

len=input.int(title="์ดํ‰์„ ",defval = 50)

ma50 = ta.sma(close, len)

plot(ma50,title="์ดํ‰์„ ",color = color.orange)


f_total_signal() =>

ย  ย  // Long conditions

ย  ย  c1_long = (high > close)

ย  ย  c2_long = close > high[2]

ย  ย  c3_long = high[2] > high[1]

ย  ย  c4_long = high[1] > low

ย  ย  c5_long = low > low[2]

ย  ย  c6_long = low[2] > low[1]

ย  ย  c7_long = close > ma50


ย  ย  longCondition = c1_long and c2_long and c3_long and c4_long and c5_long and c6_long and c7_long


ย  ย  // Short conditions

ย  ย  c1_short = (low < close)ย 

ย  ย  c2_short = close < low[2]

ย  ย  c3_short = low[2] < low[1]

ย  ย  c4_short = low[1] < high

ย  ย  c5_short = high < high[2]

ย  ย  c6_short = high[2] < high[1]

ย  ย  c7_short = close < ma50


ย  ย  shortCondition = c1_short and c2_short and c3_short and c4_short and c5_short and c6_short and c7_short


ย  ย  // ์‹ ํ˜ธ ๋ฐ˜ํ™˜: Long์ด๋ฉด 2, Short์ด๋ฉด 1, ์•„๋‹ˆ๋ฉด 0

ย  ย  longCondition ? 2 : (shortCondition ? 1 : 0)


// ํ˜„์žฌ ์บ”๋“ค ๊ธฐ์ค€ ํŒจํ„ด ์‹ ํ˜ธ ๊ณ„์‚ฐ

signal = f_total_signal()


// ์ฐจํŠธ์— ์‹ ํ˜ธ ํ‘œ์‹œ

plotshape(signal == 2, title="Long Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Long", size=size.tiny)

plotshape(signal == 1, title="Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Short", size=size.tiny)


// ์ „๋žต ์ง„์ž…: ํฌ์ง€์…˜ ์ง„์ž…์€ ์‹ ํ˜ธ ๋ฐœ์ƒ ์‹œ, ํฌ์ง€์…˜ ์ฒญ์‚ฐ์€ ๋ณ„๋„๋กœ ๊ด€๋ฆฌํ•˜์„ธ์š”.

if (signal == 2) and (strategy.position_size <= 0)

ย  ย  strategy.entry("Long", strategy.long)


if (signal == 1) and (strategy.position_size >= 0)ย 

ย  ย  strategy.entry("Short", strategy.short)