예스스탁
예스스탁 답변
2025-06-23 16:09:16
안녕하세요
예스스탁입니다.
input : len1(5);
input : len2(50);
input : col1(Lime);
input : col2(Blue);
var : hh(0),ll(0),mid(0),hma(0),change(0);
hh = highest(h,len2);
ll = lowest(l,len2);
mid = (hh+ll)/2;
HMA = wma(2 * wma(c, 50 / 2) - wma(c, 50), round(sqrt(50),0));
change = hma-hma[len1];
var : trail(Nan),color(Nan);
if change > 0 Then
{
trail = hma;
color = Violet;
}
if change < 0 Then
{
trail = hma;
color = lime;
}
plot1(trail,"trail",color,Def,2);
#type lines
# line l
# label lbl
# bool direction
#var data = array.new<lines>()
var : cnt(0);
Array : vv[100](0),tx[100](0),lbl[100](0),tl[100](0),dd[100](0);
if hh[1] == high[1] and high < hh and change > 0 Then
{
For cnt = 99 DownTo 1
{
vv[cnt] = vv[cnt-1];
tx[cnt] = tx[cnt-1];
lbl[cnt] = lbl[cnt-1];
tl[cnt] = tl[cnt-1];
dd[cnt] = dd[cnt-1];
}
vv[0] = high[1];
dd[0] = 1;
tx[0] = Text_New(sDate[1],sTime[1],vv[0],"■");
Text_SetStyle(tx[0],2,1);
Text_SetColor(tx[0],col2);
lbl[0] = text_new(sDate[1],sTime[1],vv[0], NumToStr(vv[0],2));
Text_SetColor(lbl[0],col2);
Text_SetStyle(lbl[0],0,1);
tl[0] = TL_New(sDate[1],sTime[1],vv[0],sDate,sTime,vv[0]);
TL_SetColor(tl[0],col2);
}
if ll[1] == low[1] and low > ll and change < 0 Then
{
For cnt = 99 DownTo 1
{
vv[cnt] = vv[cnt-1];
tx[cnt] = tx[cnt-1];
lbl[cnt] = lbl[cnt-1];
tl[cnt] = tl[cnt-1];
dd[cnt] = dd[cnt-1];
}
vv[0] = low[1];
dd[0] = -1;
tx[0] = Text_New(sDate[1],sTime[1],vv[0],"■");
Text_SetStyle(tx[0],2,0);
Text_SetColor(tx[0],col1);
lbl[0] = text_new(sDate[1],sTime[1],vv[0], NumToStr(vv[0],2));
Text_SetColor(lbl[0],col1);
Text_SetStyle(lbl[0],0,0);
tl[0] = TL_New(sDate[1],sTime[1],vv[0],sDate,sTime,vv[0]);
TL_SetColor(tl[0],col1);
}
For cnt = 0 to 99
{
if vv[cnt] > 0 Then
{
TL_SetEnd(TL[cnt],sDate,sTime,vv[cnt]);
Text_SetLocation(lbl[cnt],sDate,stime,vv[cnt]);
if dd[cnt] == 1 and h >= vv[cnt] Then
{
vv[cnt] = 0;
Text_Delete(lbl[cnt]);
TL_SetStyle(tl[cnt],3);
}
if dd[cnt] == -1 and l <= vv[cnt] Then
{
vv[cnt] = 0;
Text_Delete(lbl[cnt]);
TL_SetStyle(tl[cnt],3);
}
}
if cnt == 99 Then
{
TL_Delete(tl[cnt]);
Text_Delete(lbl[cnt]);
}
}
즐거운 하루되세요
> 고도산 님이 쓴 글입니다.
> 제목 : 지표 부탁드려요!!!
> 다음 TradingView 지표를 Yestrader로 부탁드립니다. 참고로 Grok Ai에다가 ta.change(src,length) 함수를 의뢰했더니 다음 1과 같이 보내왔습니다.
1. _Change(src, len) 함수
// 사용자 정의 change 함수 구현
_Change(source, length) =>
source - source[length]
2. TV 지표 수식(HMA Swing Levels [BigBeluga])
// INPUTS ――――――――――――――――――――{
len1 = input.int(5, "Trend Change")
len2 = input.int(50, "Swing Levels")
col1 = input.color(#238be0, "", inline = "col")
col2 = input.color(#1ae382, "", inline = "col")
h = ta.highest(len2)
l = ta.lowest(len2)
mid = math.avg(h, l)
hma = ta.hma(close, 50)
change = ta.change(hma, len1)
var trail = float(na)
var color = color(na)
type lines
line l
label lbl
bool direction
var data = array.new<lines>()
// }
// CALCULATIONS――――――――――{
if last_bar_index - bar_index < 4000
if h[1] == high[1] and high < h and change > 0
label.new(bar_index[1], high[1], "▇", style = label.style_label_center, color = color(na), textcolor = col2, size = size.tiny)
lbl = label.new(bar_index[1], high[1], str.tostring(high[1]), style = label.style_label_left, color = color(na), textcolor = col2, size = size.normal)
l1 = line.new(bar_index[1], high[1], bar_index, high[1], color = col2)
gg = lines.new(l1, lbl, false)
data.push(gg)
if l[1] == low[1] and low > l and change < 0
label.new(bar_index[1], low[1], "▇", style = label.style_label_center, color = color(na), textcolor = col1, size = size.tiny)
lbl = label.new(bar_index[1], low[1], str.tostring(low[1]), style = label.style_label_left, color = color(na), textcolor = col1, size = size.normal)
l2 = line.new(bar_index[1], low[1], bar_index, low[1], color = col1)
gg = lines.new(l2, lbl, true)
data.push(gg)
if data.size() > 0
for gg in data
l_ = gg.l
lbl = gg.lbl
l_.set_x2(bar_index)
lbl.set_x(bar_index)
if l_.get_x2() - l_.get_x1() > 250
l_.set_width(2)
if l_.get_x2() - l_.get_x1() > 500
l_.set_width(3)
if l_.get_x2() - l_.get_x1() > 750
l_.set_width(4)
if gg.direction
if low < l_.get_y1()
l_.set_width(1)
label.delete(lbl)
l_.set_style(line.style_dashed)
ss = lines.new(line(na), label(na))
data.set(data.indexof(gg), ss)
else
if high > l_.get_y1()
l_.set_width(1)
label.delete(lbl)
l_.set_style(line.style_dashed)
ss = lines.new(line(na), label(na))
data.set(data.indexof(gg), ss)
if change > 0
trail := hma
color := color.fuchsia
if change < 0
trail := hma
color := color.lime
pt = plot(trail, color = color, style = plot.style_stepline, linewidth = 2)
plot(trail, color = color.new(color, 60), style = plot.style_stepline, linewidth = 6)
// }