예스스탁
예스스탁 답변
2025-05-08 13:41:29
안녕하세요
예스스탁입니다.
input : fast(12);
input : slow(26);
input : signal(9);
input : length(100);
input : multiplier(2);
var : macd_line(0),signal_line(0);
var : lower_boll(0),upper_boll(0),mid_line(0);
var : buy_signal(False),sell_signal(False),tx(0),cnt(0);
array : tl1[20](0),tl2[20](0),ii[20](0);
macd_line = ema(close, fast) - ema(close, slow);
signal_line = ema(macd_line, signal);
lower_boll = ma(close, length) - (multiplier * std(close, length));
upper_boll = ma(close, length) + (multiplier * std(close, length));
mid_line = ma(close, length);
buy_signal = min(open[1], close[1]) <= lower_boll[1] and max(open[1], close[1]) <= mid_line and macd_line[1] > signal_line[1] and macd_line[2] < signal_line[2];
sell_signal = max(open[1], close[1]) >= upper_boll[1] and min(open[1], close[1]) >= mid_line and macd_line[1] < signal_line[1] and macd_line[2] > signal_line[2];
if buy_signal == true Then
{
tx = Text_New(sDate,sTime,L,"▲");
Text_SetStyle(tx,2,0);
Text_SetColor(tx,Green);
var1 = low[1] - (high[1] - low[1]) * 2;
var2 = O;
For cnt = 19 downto 1
{
TL1[cnt] = TL1[cnt-1];
TL2[cnt] = TL2[cnt-1];
ii[cnt] = ii[cnt-1];
}
TL1[0] = TL_New(sDate,sTime,var1,NextBarSdate,NextBarStime,var1);
TL_SetColor(TL1[0],Red);
TL2[0] = TL_New(sDate,sTime,var2,NextBarSdate,NextBarStime,var2);
TL_SetColor(TL2[0],Blue);
ii[0] = Index;
}
Else if sell_signal == true Then
{
tx = Text_New(sDate,sTime,H,"▼");
Text_SetStyle(tx,2,1);
Text_SetColor(tx,Red);
var1 = high[1] + (high[1] - low[1]) * 2;
var2 = O;
For cnt = 19 downto 1
{
TL1[cnt] = TL1[cnt-1];
TL2[cnt] = TL2[cnt-1];
ii[cnt] = ii[cnt-1];
}
TL1[0] = TL_New(sDate,sTime,var1,NextBarSdate,NextBarStime,var1);
TL_SetColor(TL1[0],Red);
TL2[0] = TL_New(sDate,sTime,var2,NextBarSdate,NextBarStime,var2);
TL_SetColor(TL2[0],Blue);;
ii[0] = Index;
}
Else
{
For cnt = 0 to 19
{
if ii[cnt] > 0 and Index < ii[cnt]+20 Then
{
TL_SetEnd(TL1[cnt],NextBarSdate,NextBarStime,TL_GetValue(TL1[cnt],sDate,sTime));
TL_SetEnd(TL2[cnt],NextBarSdate,NextBarStime,TL_GetValue(TL2[cnt],sDate,sTime));
}
}
}
즐거운 하루되세요
> 다올 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> indicator("K's Reversal Indicator I", overlay = true)
fast = input(defval = 12, title = 'Fast')
slow = input(defval = 26, title = 'Slow')
signal = input(defval = 9, title = 'Signal')
length = input(defval = 100, title = 'Bollinger Lookback')
multiplier = input(defval = 2, title = 'Multiplier')
// MACD
macd_line = ta.ema(close, fast) - ta.ema(close, slow)
signal_line = ta.ema(macd_line, signal)
// Bollinger
lower_boll = ta.sma(close, length) - (multiplier * ta.stdev(close, length))
upper_boll = ta.sma(close, length) + (multiplier * ta.stdev(close, length))
mid_line = ta.sma(close, length)
// Signal
buy_signal = math.min(open[1], close[1]) <= lower_boll[1] and math.max(open[1], close[1]) <= mid_line and macd_line[1] > signal_line[1] and macd_line[2] < signal_line[2]
sell_signal = math.max(open[1], close[1]) >= upper_boll[1] and math.min(open[1], close[1]) >= mid_line and macd_line[1] < signal_line[1] and macd_line[2] > signal_line[2]
// Plotting
plotshape(buy_signal, style = shape.triangleup, color = color.green, location = location.belowbar, size = size.small)
plotshape(sell_signal, style = shape.triangledown, color = color.red, location = location.abovebar, size = size.small)
bar_size = timeframe.multiplier * (timeframe.isdaily?1440:timeframe.isweekly?7*1440:timeframe.ismonthly?30*1440:1) * 60*1000
if buy_signal == true
line.new(time, low[1] - (high[1] - low[1]) * 2, time + bar_size * 20, low[1] - (high[1] - low[1]) * 2, xloc.bar_time, color = color.green, width = 2)
line.new(time, open, time + bar_size * 20, open, xloc.bar_time, color = color.blue, width = 2)
if sell_signal == true
line.new(time, high[1] + (high[1] - low[1]) * 2, time + bar_size * 20, high[1] + (high[1] - low[1]) * 2, xloc.bar_time, color = color.red, width = 2)
line.new(time, open, time + bar_size * 20, open, xloc.bar_time, color = color.blue, width = 2)