답변완료
문의 드립니다.
//@version=3
study("GMMA fill", overlay=true)
//input ------
src = input(close, title="source")
len1 = input(3, title="short length 1")
len2 = input(5, title="short length 2")
len3 = input(8, title="short length 3")
len4 = input(10, title="short length 4")
len5 = input(12, title="short length 5")
len6 = input(15, title="short length 6")
len7 = input(30, title="long length 1")
len8 = input(35, title="long length 2")
len9 = input(40, title="long length 3")
len10 = input(45, title="long length 4")
len11 = input(50, title="long length 5")
len12 = input(60, title="long length 6")
trend_color = input(false, title="trend color")
//ema -----
s1 = ema(src, len1)
s2 = ema(src, len2)
s3 = ema(src, len3)
s4 = ema(src, len4)
s5 = ema(src, len5)
s6 = ema(src, len6)
l1 = ema(src, len7)
l2 = ema(src, len8)
l3 = ema(src, len9)
l4 = ema(src, len10)
l5 = ema(src, len11)
l6 = ema(src, len12)
//trend
trend_up_s = s1 > s2 and s2 > s3 and s3 > s4 and s4 > s5 and s5 > s6
trend_up_l = l1 > l2 and l2 > l3 and l3 > l4 and l4 > l5 and l5 > l6
trend_down_s = s1 < s2 and s2 < s3 and s3 < s4 and s4 < s5 and s5 < s6
trend_down_l = l1 < l2 and l2 < l3 and l3 < l4 and l4 < l5 and l5 < l6
color_s = trend_color and trend_up_s ? #32cd32 : trend_color and trend_down_s ? red : trend_color ? gray : #32cd32
color_l = trend_color and trend_up_l ? #32cd32 : trend_color and trend_down_l ? red : trend_color ? gray : red
//plot -----
p_l1 = plot(l1, color=color_l, title="long 1", linewidth=2)
p_l2 = plot(l2, color=color_l, title="long 2")
p_l3 = plot(l3, color=color_l, title="long 3")
p_l4 = plot(l4, color=color_l, title="long 4")
p_l5 = plot(l5, color=color_l, title="long 5")
p_l6 = plot(l6, color=color_l, title="long 6", linewidth=2)
p_s1 = plot(s1, color=color_s, title="short 1", linewidth=2)
p_s2 = plot(s2, color=color_s, title="short 2")
p_s3 = plot(s3, color=color_s, title="short 3")
p_s4 = plot(s4, color=color_s, title="short 4")
p_s5 = plot(s5, color=color_s, title="short 5")
p_s6 = plot(s6, color=color_s, title="short 6", linewidth=2)
//fill -----
fill(p_l1, p_l6, color_l, 80, "fill long 1-6")
fill(p_s1, p_s6, color_s, 80, "fill short 1-6")
//GCDC -----
disp_gcdc = input("na", options=["na", "circles", "label"], title="display GC/DC")
gmma_cross(gmma) =>
flag = 0
if gmma > l1 and gmma > l2 and gmma > l3 and gmma > l4 and gmma > l5 and gmma > l6
flag := 1
if gmma < l1 and gmma < l2 and gmma < l3 and gmma < l4 and gmma < l5 and gmma < l6
flag := -1
flag
s1_cross = gmma_cross(s1)
s2_cross = gmma_cross(s2)
s3_cross = gmma_cross(s3)
s4_cross = gmma_cross(s4)
s5_cross = gmma_cross(s5)
s6_cross = gmma_cross(s6)
cross_cnt = s1_cross + s2_cross + s3_cross + s4_cross + s5_cross
gc = cross_cnt==5 and crossover(s6_cross, 0) ? true : false
dc = cross_cnt==-5 and crossunder(s6_cross, 0) ? true : false
plotshape(gc and disp_gcdc=="label", style=shape.labeldown, color=green, transp=0, location=location.abovebar, text="GC", textcolor=white, title="GC label")
plotshape(dc and disp_gcdc=="label", style=shape.labelup, color=maroon, transp=0, location=location.belowbar, text="DC", textcolor=white, title="DC label")
plot(disp_gcdc=="circles" ? s6 : na, style=circles, linewidth=4, color= gc ? lime : dc ? red : na, transp=0, title="GC/DC circles")
alertcondition(gc or dc, "1. Alert GMMA cross", "GMMA cross")
alertcondition(gc, "2. Alert GMMA GC", "GMMA GC")
alertcondition(dc, "3. Alert GMMA DC", "GMMA DC")
트레이딩뷰 지표인데 선만 예스로 좀 바꿔주세요.
2024-08-14
908
글번호 182545
지표
답변완료
추세선 수식 해석 관련해서 질문드립니다
전에 질문드렸던 추세선 관련해서 추가적으로 여쭤보고싶습니다
일단 수식은 아래와 같습니다
var : n(30);
var : cnt(0),hh(0),hb(0),ll(0),lb(0),TL(0),TX(0);
#최근 n봉안에 봉길이는 4%이상이고 하락시가갭 3%인 봉이 있을 때
if CountIf(H >= L*1.11,n) >= 1 Then
{
#"최근봉"만 표시되게 하기위해 "직전에서 출력된 추세선과 텍스트는 삭제"
//TL_Delete(TL);
//Text_Delete(TX);
#n개봉 최고가와 최고가위치(몇봉전인지) 계산
#n개봉 최저가와 최저가위치(몇봉전인지) 계산
hh = 0;
hb = 0;
ll = 0;
lb = 0;
For cnt = 0 to n-1
{
if hh == 0 or (hh > 0 and h[cnt] > hh) Then
{
hh = h[cnt];
hb = cnt; }
if ll == 0 or (ll > 0 and l[cnt] < ll) Then
{
ll = l[cnt];
lb = cnt;
} }
#추세선 출력
TL = TL_New(sDate[hb],sTime[hb],hh,sDate[lb],sTime[lb],ll);
#최고가가 더 가까우면 빨강 아니면 파랑
if lb > hb Then
TL_SetColor(TL,Red);
//TL_SetSize(tl,2);
Else
TL_SetColor(TL,Blue);
#텍스트 출력
TX = Text_New(TL_GetEndDate(TL),TL_GetEndTime(TL),TL_GetEndVal(TL),NumToStr(abs(hb-lb),0));
}
제가 해석한대로라면 n기간 (30봉) 동안 고가 저가 길이가 11% 이상인 봉이 한번 이상 발생한다면 추세선을 만드는거고 30봉 동안의 저점과 고점을 연결함. 그리고 상향 추세선이면 red로, 하향이면 blue 로 표현
이게 해석이 맞나요??
맞다면 추세선의 양끝단의 등락률 조건을 추가로 넣을 수 있을까요?
예를 들면 상향 추세선일때는 start의 저점과 end 의 고점의 차이가 30% 이상일때 만 추세선이 나타나게 하고, 하향선일때는 start 고점과 end 저점의 차이가 20% 이상일때 각각 나눠서 나타내고 싶습니다
+ 추세선을 돌파하는 식은 어떻게 나타내야 하나요?
추세선 돌파하거나 가로지르는 조건은 작성이 안되는건가요?~
if crossup(c,TL), then plot3(high,"tlcross") ;
이렇게 해봤는데 아닌거 같네요
+ 선굵기를 조정하고 싶은데요
아래 부분에서 선 굵기를 tl_setsize로 조정하려고 하는데 문법에러 else 라고 나옵니다
#최고가가 더 가까우면 빨강 아니면 파랑
if lb > hb Then
TL_SetColor(TL,Red);
TL_SetSize(tl,2);
Else
TL_SetColor(TL,Blue);
2024-08-13
852
글번호 182528
지표