커뮤니티

수식 부탁드립니다.

프로필 이미지
예시스
2016-05-07 14:53:51
200
글번호 97792
답변완료
아래 두 식은 수식지왕님의 블로그에서 참조(주석생략)한 식인데요. 두 식 모두 고점과 저점을 수평선(Plot)으로 잇는 식을 부탁드립니다. 예전에 답해주셨던 게시물 내용을 참조로 스스로 식을 작성해 보았지만 아직 초보의 한계를 벗어나지 못하고 있네요. 잘 부탁드리며 항상 적극적인 도움을 주셔서 감사드립니다. 1번 식 #==========================================# # 지표명 : 지그재그파동(변동률) # 작성자 : 수식지왕 # 블로그 : http://yahoosir.blog.me #==========================================# Input:chngRate(5); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; Condition1 = Min(valArr[1],valArr[2]) * (1 + (chngRate/100)) < H and lastHiVal < H; Condition2 = Max(valArr[1],valArr[2]) * (1 - (chngRate/100)) > L and (lastLoVal > L || lastLoVal == 0); If Condition1 Then { lastHiVal = H; lastLoVal = 0; } If Condition2 Then { lastLoVal = L; lastHiVal = 0; } turnPntBit = ""; If Condition1 and Condition2 Then { If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else If turnPntArr[1] == "Lo" Then turnPntBit = "Hi"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit == "Hi" or turnPntBit == "Lo" Then { If turnPntBit <> turnPntArr[1] Then { for j = 18 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); TL_SetColor(TL1,Black); 2번 식 Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0), Text1(0),처리구분(""); Array:고점[10,2](0),저점[10,2](0); //가격,위치 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1], NumToStr(고점[1,1],2)); Text_SetStyle(Text1, 2, 1); } } If 처리구분 == "저점처리" Then { lastLoVal = L; If 저점[1,2] < 고점[1,2] then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1], NumToStr(저점[1,1],2)); Text_SetStyle(Text1, 2, 0); } } TL_SetSize(TL1,3); TL_SetColor(TL1,CYAN);
지표
답변 3
프로필 이미지

예스스탁 예스스탁 답변

2016-05-09 14:55:20

안녕하세요 예스스탁입니다. 1. Input:chngRate(5); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0),TL2(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; } Condition1 = Min(valArr[1],valArr[2]) * (1 + (chngRate/100)) < H and lastHiVal < H; Condition2 = Max(valArr[1],valArr[2]) * (1 - (chngRate/100)) > L and (lastLoVal > L || lastLoVal == 0); If Condition1 Then { lastHiVal = H; lastLoVal = 0; } If Condition2 Then { lastLoVal = L; lastHiVal = 0; } turnPntBit = ""; If Condition1 and Condition2 Then { If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else If turnPntArr[1] == "Lo" Then turnPntBit = "Hi"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit == "Hi" or turnPntBit == "Lo" Then { If turnPntBit <> turnPntArr[1] Then { for j = 18 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then{ TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); TL2 = TL_New(sDate[barArr[4]],sTime[barArr[4]],valArr[4],sDate[barArr[2]],sTime[barArr[2]],valArr[2]); if turnPntArr[2] == "Hi" Then TL_SetColor(TL2,RED); Else TL_SetColor(TL2,blue); } Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); TL_SetColor(TL1,Black); 2 Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0),TL2(0), Text1(0),처리구분(""),T(0); Array:고점[10,2](0),저점[10,2](0); //가격,위치 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1], NumToStr(고점[1,1],2)); Text_SetStyle(Text1, 2, 1); } } If 처리구분 == "저점처리" Then { lastLoVal = L; If 저점[1,2] < 고점[1,2] then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1], NumToStr(저점[1,1],2)); Text_SetStyle(Text1, 2, 0); } } TL_SetSize(TL1,3); TL_SetColor(TL1,CYAN); If 처리구분 == "고점처리" Then T = 1; If 처리구분 == "저점처리" Then T = -1; if T == -1 and T[1] != -1 Then{ TL2 = TL_New(sDate[index-고점[2,2]],sTime[index-고점[2,2]],고점[2,1],sDate[index-고점[1,2]],sTime[index-고점[1,2]],고점[1,1]); TL_SetColor(TL2,red); } if T == 1 and T[1] != 1 Then{ TL2 = TL_New(sDate[index-저점[2,2]],sTime[index-저점[2,2]],저점[2,1],sDate[index-저점[1,2]],sTime[index-저점[1,2]],저점[1,1]); TL_SetColor(TL2,blue); } 즐거운 하루되세요 > 예시스 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 아래 두 식은 수식지왕님의 블로그에서 참조(주석생략)한 식인데요. 두 식 모두 고점과 저점을 수평선(Plot)으로 잇는 식을 부탁드립니다. 예전에 답해주셨던 게시물 내용을 참조로 스스로 식을 작성해 보았지만 아직 초보의 한계를 벗어나지 못하고 있네요. 잘 부탁드리며 항상 적극적인 도움을 주셔서 감사드립니다. 1번 식 #==========================================# # 지표명 : 지그재그파동(변동률) # 작성자 : 수식지왕 # 블로그 : http://yahoosir.blog.me #==========================================# Input:chngRate(5); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; Condition1 = Min(valArr[1],valArr[2]) * (1 + (chngRate/100)) < H and lastHiVal < H; Condition2 = Max(valArr[1],valArr[2]) * (1 - (chngRate/100)) > L and (lastLoVal > L || lastLoVal == 0); If Condition1 Then { lastHiVal = H; lastLoVal = 0; } If Condition2 Then { lastLoVal = L; lastHiVal = 0; } turnPntBit = ""; If Condition1 and Condition2 Then { If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else If turnPntArr[1] == "Lo" Then turnPntBit = "Hi"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit == "Hi" or turnPntBit == "Lo" Then { If turnPntBit <> turnPntArr[1] Then { for j = 18 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); TL_SetColor(TL1,Black); 2번 식 Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0), Text1(0),처리구분(""); Array:고점[10,2](0),저점[10,2](0); //가격,위치 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1], NumToStr(고점[1,1],2)); Text_SetStyle(Text1, 2, 1); } } If 처리구분 == "저점처리" Then { lastLoVal = L; If 저점[1,2] < 고점[1,2] then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1], NumToStr(저점[1,1],2)); Text_SetStyle(Text1, 2, 0); } } TL_SetSize(TL1,3); TL_SetColor(TL1,CYAN);
프로필 이미지

예시스

2016-05-09 15:34:19

연휴 뒤라 바쁘실 텐데도 신속한 답변 주셔서 깊이 감사드립니다. 작성해 주신 식을 적용해 봤더니 고점:저점의 수평선 연결이 아니라 저:저, 고:고 점이 사선으로 연결되는 내용이었습니다. 예전에 어떤 분에게 답변으로 올려주셨던 고점:저점 연결 수평선식을 아래 첨부했는데요. 이 첨부식에서 출력되는 Plot2를 표시해 주는 지표식을 부탁드렸던 것인데 다시 한 번 부탁드려도 될는지요? 감사합니다. ₩₩₩₩₩₩₩₩₩₩₩₩₩₩ 첨부 식 ₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩ Input:상승률(0.5),하락률(0.5); Var:j(0),상승(100),하락(-100),양방향(2),색깔(0),파랑(-1),빨강(1), 기준고(0),기준저(0),기준고Bar(0),기준저Bar(0),추세(0),이중파동(0); var : hbody(0),lbody(0); Array:고[20](0),저[20](0),고Bar[20](0),저Bar[20](0); Hbody = max(C,O); Lbody = min(c,O); #==========================================# # 전고점,전저점 index 증가 #==========================================# For j = 1 To 19 { 저Bar[j] = 저Bar[j] + 1; 고Bar[j] = 고Bar[j] + 1; } #==========================================# # 이중파동 처리 #==========================================# If 이중파동 > 0 Then { if 색깔 == 빨강 Then{ Plot1(이중파동,"Zigzag",blue); var2 = 이중파동; var3 = -1; } Else{ Plot1(이중파동,"Zigzag",red); var1 = 이중파동; var3 = 1; } 이중파동 = 0; } #==========================================# # 최근 고,저 갱신 #==========================================# If 기준고 <= Hbody || 기준고 == 0 || IsNaN(기준고) == True Then { 기준고 = Hbody; 기준고Bar = 0; } Else 기준고Bar = 기준고Bar + 1; If 기준저 >= Lbody || 기준저 == 0 || IsNaN(기준저) == True Then { 기준저 = Lbody; 기준저Bar = 0; } Else 기준저Bar = 기준저Bar + 1; #==========================================# # 추세방향 결정 #==========================================# If 기준고 * (1 - (하락률/100)) > Hbody && 기준저 * (1 + (상승률/100)) < Lbody Then { 추세 = Iff(기준고Bar==기준저Bar,양방향,Iff(기준고Bar>기준저Bar,상승,하락)); } Else If 기준고 * (1 - (하락률/100)) > Hbody Then 추세 = 하락; Else If 기준저 * (1 + (상승률/100)) < Lbody Then 추세 = 상승; #==========================================# # 추세변화에 따른 변곡점 처리 #==========================================# If 추세[1] == 상승 && 추세 == 하락 Then { For j = 18 DownTo 1 { 고[j+1] = 고[j]; 고Bar[j+1] = 고Bar[j]; } 고[1] = 기준고; 고Bar[1] = 기준고Bar; 기준고 = Hbody; 기준고Bar = 0; 기준저 = Lbody; 기준저Bar = 0; If 고[2] < 고[1] Then 색깔 = 빨강 ; If 이중파동[1] > 0 Then 이중파동 = 고[1]; Else { plot1(고[1],"Zigzag",RED); var1 = 고[1]; var3 = 1; } } If 추세[1] == 하락 && 추세 == 하락 && 고[1] < 기준고 && 기준고 * (1 - (하락률/100)) > Hbody Then { For j = 18 DownTo 1 { 고[j+1] = 고[j]; 고Bar[j+1] = 고Bar[j]; 저[j+1] = 저[j]; 저Bar[j+1] = 저Bar[j]; } 고[1] = 기준고; 고Bar[1] = 기준고Bar; 저[1] = 기준저; 저Bar[1] = 기준저Bar; 기준고 = Hbody; 기준고Bar = 0; 기준저 = Lbody; 기준저Bar = 0; If 저[2] > 저[1] Then 색깔 = 파랑; plot1(저[1],"Zigzag",blue); var2 = 저[1]; var3 = -1; If 고[2] < 고[1] Then 색깔 = 빨강; 이중파동 = 고[1]; } If 추세[1] == 하락 && 추세 == 상승 Then { For j = 18 DownTo 1 { 저[j+1] = 저[j]; 저Bar[j+1] = 저Bar[j]; } 저[1] = 기준저; 저Bar[1] = 기준저Bar; 기준저 = Lbody; 기준저Bar = 0; 기준고 = Hbody; 기준고Bar = 0; If 저[2] > 저[1] Then 색깔 = 파랑; If 이중파동[1] > 0 Then 이중파동 = 저[1]; Else { plot1(저[1],"Zigzag",blue); var2 = 저[1]; var3 = -1; } } If 추세[1] == 상승 && 추세 == 상승 && 저[1] > 기준저 && 기준저 * (1 + (상승률/100)) < Lbody Then { For j = 18 DownTo 1 { 고[j+1] = 고[j]; 고Bar[j+1] = 고Bar[j]; 저[j+1] = 저[j]; 저Bar[j+1] = 저Bar[j]; } 고[1] = 기준고; 고Bar[1] = 기준고Bar; 저[1] = 기준저; 저Bar[1] = 기준저Bar; 기준저 = Lbody; 기준저Bar = 0; 기준고 = Hbody; 기준고Bar = 0; If 고[2] < 고[1] Then 색깔 = 빨강; plot1(고[1],"Zigzag",RED); var1 = 고[1]; var3 = 1; If 저[2] > 저[1] Then 색깔 = 파랑; 이중파동 = 저[1]; } If 추세 == 양방향 Then { For j = 18 DownTo 1 { 고[j+1] = 고[j]; 고Bar[j+1] = 고Bar[j]; 저[j+1] = 저[j]; 저Bar[j+1] = 저Bar[j]; } 고[1] = 기준고; 고Bar[1] = 기준고Bar; 저[1] = 기준저; 저Bar[1] = 기준저Bar; 기준고 = Hbody; 기준고Bar = 0; 기준저 = Lbody; 기준저Bar = 0; 추세 = 추세[1]; If 추세[1] == 상승 Then { If 고[2] < 고[1] Then 색깔 = 빨강; Plot1(고[1],"Zigzag",RED); var1 = 고[1]; var3 = 1; If 저[2] > 저[1] Then 색깔 = 파랑; 이중파동 = 저[1]; } Else { If 저[2] > 저[1] Then 색깔 = 파랑; Plot1(저[1],"Zigzag",blue); Text_New(sdate,stime,저[1],NumToStr(저[1],2)); var2 = 저[1]; var3 = -1; If 고[2] < 고[1] Then 색깔 = 빨강; 이중파동 = 고[1]; } } if var3 == -1 Then{ plot2(var2); } if var3 == 1 Then{ plot2(var1); } ₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩ 첨 부 끝 ₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩ > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 부탁드립니다. > 안녕하세요 예스스탁입니다. 1. Input:chngRate(5); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0),TL2(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; } Condition1 = Min(valArr[1],valArr[2]) * (1 + (chngRate/100)) < H and lastHiVal < H; Condition2 = Max(valArr[1],valArr[2]) * (1 - (chngRate/100)) > L and (lastLoVal > L || lastLoVal == 0); If Condition1 Then { lastHiVal = H; lastLoVal = 0; } If Condition2 Then { lastLoVal = L; lastHiVal = 0; } turnPntBit = ""; If Condition1 and Condition2 Then { If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else If turnPntArr[1] == "Lo" Then turnPntBit = "Hi"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit == "Hi" or turnPntBit == "Lo" Then { If turnPntBit <> turnPntArr[1] Then { for j = 18 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then{ TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); TL2 = TL_New(sDate[barArr[4]],sTime[barArr[4]],valArr[4],sDate[barArr[2]],sTime[barArr[2]],valArr[2]); if turnPntArr[2] == "Hi" Then TL_SetColor(TL2,RED); Else TL_SetColor(TL2,blue); } Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); TL_SetColor(TL1,Black); 2 Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0),TL2(0), Text1(0),처리구분(""),T(0); Array:고점[10,2](0),저점[10,2](0); //가격,위치 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1], NumToStr(고점[1,1],2)); Text_SetStyle(Text1, 2, 1); } } If 처리구분 == "저점처리" Then { lastLoVal = L; If 저점[1,2] < 고점[1,2] then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1], NumToStr(저점[1,1],2)); Text_SetStyle(Text1, 2, 0); } } TL_SetSize(TL1,3); TL_SetColor(TL1,CYAN); If 처리구분 == "고점처리" Then T = 1; If 처리구분 == "저점처리" Then T = -1; if T == -1 and T[1] != -1 Then{ TL2 = TL_New(sDate[index-고점[2,2]],sTime[index-고점[2,2]],고점[2,1],sDate[index-고점[1,2]],sTime[index-고점[1,2]],고점[1,1]); TL_SetColor(TL2,red); } if T == 1 and T[1] != 1 Then{ TL2 = TL_New(sDate[index-저점[2,2]],sTime[index-저점[2,2]],저점[2,1],sDate[index-저점[1,2]],sTime[index-저점[1,2]],저점[1,1]); TL_SetColor(TL2,blue); } 즐거운 하루되세요 > 예시스 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 아래 두 식은 수식지왕님의 블로그에서 참조(주석생략)한 식인데요. 두 식 모두 고점과 저점을 수평선(Plot)으로 잇는 식을 부탁드립니다. 예전에 답해주셨던 게시물 내용을 참조로 스스로 식을 작성해 보았지만 아직 초보의 한계를 벗어나지 못하고 있네요. 잘 부탁드리며 항상 적극적인 도움을 주셔서 감사드립니다. 1번 식 #==========================================# # 지표명 : 지그재그파동(변동률) # 작성자 : 수식지왕 # 블로그 : http://yahoosir.blog.me #==========================================# Input:chngRate(5); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; Condition1 = Min(valArr[1],valArr[2]) * (1 + (chngRate/100)) < H and lastHiVal < H; Condition2 = Max(valArr[1],valArr[2]) * (1 - (chngRate/100)) > L and (lastLoVal > L || lastLoVal == 0); If Condition1 Then { lastHiVal = H; lastLoVal = 0; } If Condition2 Then { lastLoVal = L; lastHiVal = 0; } turnPntBit = ""; If Condition1 and Condition2 Then { If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else If turnPntArr[1] == "Lo" Then turnPntBit = "Hi"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit == "Hi" or turnPntBit == "Lo" Then { If turnPntBit <> turnPntArr[1] Then { for j = 18 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); TL_SetColor(TL1,Black); 2번 식 Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0), Text1(0),처리구분(""); Array:고점[10,2](0),저점[10,2](0); //가격,위치 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1], NumToStr(고점[1,1],2)); Text_SetStyle(Text1, 2, 1); } } If 처리구분 == "저점처리" Then { lastLoVal = L; If 저점[1,2] < 고점[1,2] then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1], NumToStr(저점[1,1],2)); Text_SetStyle(Text1, 2, 0); } } TL_SetSize(TL1,3); TL_SetColor(TL1,CYAN);
프로필 이미지

예스스탁 예스스탁 답변

2016-05-09 17:48:26

안녕하세요 예스스탁입니다. 식을 수정했습니다. 올려주신 내용은 plot으로는 해결되지 않습니다. 수평선도 추세선함수로 출력되게 작성했습니다. 1. Input:chngRate(5); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0),TL2(0),TL3(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; } Condition1 = Min(valArr[1],valArr[2]) * (1 + (chngRate/100)) < H and lastHiVal < H; Condition2 = Max(valArr[1],valArr[2]) * (1 - (chngRate/100)) > L and (lastLoVal > L || lastLoVal == 0); If Condition1 Then { lastHiVal = H; lastLoVal = 0; } If Condition2 Then { lastLoVal = L; lastHiVal = 0; } turnPntBit = ""; If Condition1 and Condition2 Then { If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else If turnPntArr[1] == "Lo" Then turnPntBit = "Hi"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit == "Hi" or turnPntBit == "Lo" Then { If turnPntBit <> turnPntArr[1] Then { for j = 18 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then{ TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); TL2 = TL_New(sDate[barArr[3]],sTime[barArr[3]],valArr[3],sDate[barArr[2]],sTime[barArr[2]],valArr[3]); if turnPntArr[2] == "Hi" Then TL_SetColor(TL2,blue); Else TL_SetColor(TL2,red); } Else{ TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); TL_Delete(TL3); TL3 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate,sTime,valArr[2]); if turnPntArr[2] == "Hi" Then TL_SetColor(TL3,RED); Else TL_SetColor(TL3,blue); } } } TL_SetSize(TL1,1); TL_SetColor(TL1,Black); 2 Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0),TL2(0), Text1(0),처리구분(""),T(0); Array:고점[10,2](0),저점[10,2](0); //가격,위치 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); TL_Delete(TL2); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); TL2 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1], NumToStr(고점[1,1],2)); Text_SetStyle(Text1, 2, 1); TL_SetColor(TL2,blue); } } If 처리구분 == "저점처리" Then { lastLoVal = L; If 저점[1,2] < 고점[1,2] then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); TL_Delete(TL2); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); TL2 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1], NumToStr(저점[1,1],2)); Text_SetStyle(Text1, 2, 0); TL_SetColor(TL2,RED); } } TL_SetSize(TL1,3); TL_SetColor(TL1,CYAN); 즐거운 하루되세요 > 예시스 님이 쓴 글입니다. > 제목 : Re : 신속 답변 감사드리며 재 문의 드립니다. > 연휴 뒤라 바쁘실 텐데도 신속한 답변 주셔서 깊이 감사드립니다. 작성해 주신 식을 적용해 봤더니 고점:저점의 수평선 연결이 아니라 저:저, 고:고 점이 사선으로 연결되는 내용이었습니다. 예전에 어떤 분에게 답변으로 올려주셨던 고점:저점 연결 수평선식을 아래 첨부했는데요. 이 첨부식에서 출력되는 Plot2를 표시해 주는 지표식을 부탁드렸던 것인데 다시 한 번 부탁드려도 될는지요? 감사합니다. ₩₩₩₩₩₩₩₩₩₩₩₩₩₩ 첨부 식 ₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩ Input:상승률(0.5),하락률(0.5); Var:j(0),상승(100),하락(-100),양방향(2),색깔(0),파랑(-1),빨강(1), 기준고(0),기준저(0),기준고Bar(0),기준저Bar(0),추세(0),이중파동(0); var : hbody(0),lbody(0); Array:고[20](0),저[20](0),고Bar[20](0),저Bar[20](0); Hbody = max(C,O); Lbody = min(c,O); #==========================================# # 전고점,전저점 index 증가 #==========================================# For j = 1 To 19 { 저Bar[j] = 저Bar[j] + 1; 고Bar[j] = 고Bar[j] + 1; } #==========================================# # 이중파동 처리 #==========================================# If 이중파동 > 0 Then { if 색깔 == 빨강 Then{ Plot1(이중파동,"Zigzag",blue); var2 = 이중파동; var3 = -1; } Else{ Plot1(이중파동,"Zigzag",red); var1 = 이중파동; var3 = 1; } 이중파동 = 0; } #==========================================# # 최근 고,저 갱신 #==========================================# If 기준고 <= Hbody || 기준고 == 0 || IsNaN(기준고) == True Then { 기준고 = Hbody; 기준고Bar = 0; } Else 기준고Bar = 기준고Bar + 1; If 기준저 >= Lbody || 기준저 == 0 || IsNaN(기준저) == True Then { 기준저 = Lbody; 기준저Bar = 0; } Else 기준저Bar = 기준저Bar + 1; #==========================================# # 추세방향 결정 #==========================================# If 기준고 * (1 - (하락률/100)) > Hbody && 기준저 * (1 + (상승률/100)) < Lbody Then { 추세 = Iff(기준고Bar==기준저Bar,양방향,Iff(기준고Bar>기준저Bar,상승,하락)); } Else If 기준고 * (1 - (하락률/100)) > Hbody Then 추세 = 하락; Else If 기준저 * (1 + (상승률/100)) < Lbody Then 추세 = 상승; #==========================================# # 추세변화에 따른 변곡점 처리 #==========================================# If 추세[1] == 상승 && 추세 == 하락 Then { For j = 18 DownTo 1 { 고[j+1] = 고[j]; 고Bar[j+1] = 고Bar[j]; } 고[1] = 기준고; 고Bar[1] = 기준고Bar; 기준고 = Hbody; 기준고Bar = 0; 기준저 = Lbody; 기준저Bar = 0; If 고[2] < 고[1] Then 색깔 = 빨강 ; If 이중파동[1] > 0 Then 이중파동 = 고[1]; Else { plot1(고[1],"Zigzag",RED); var1 = 고[1]; var3 = 1; } } If 추세[1] == 하락 && 추세 == 하락 && 고[1] < 기준고 && 기준고 * (1 - (하락률/100)) > Hbody Then { For j = 18 DownTo 1 { 고[j+1] = 고[j]; 고Bar[j+1] = 고Bar[j]; 저[j+1] = 저[j]; 저Bar[j+1] = 저Bar[j]; } 고[1] = 기준고; 고Bar[1] = 기준고Bar; 저[1] = 기준저; 저Bar[1] = 기준저Bar; 기준고 = Hbody; 기준고Bar = 0; 기준저 = Lbody; 기준저Bar = 0; If 저[2] > 저[1] Then 색깔 = 파랑; plot1(저[1],"Zigzag",blue); var2 = 저[1]; var3 = -1; If 고[2] < 고[1] Then 색깔 = 빨강; 이중파동 = 고[1]; } If 추세[1] == 하락 && 추세 == 상승 Then { For j = 18 DownTo 1 { 저[j+1] = 저[j]; 저Bar[j+1] = 저Bar[j]; } 저[1] = 기준저; 저Bar[1] = 기준저Bar; 기준저 = Lbody; 기준저Bar = 0; 기준고 = Hbody; 기준고Bar = 0; If 저[2] > 저[1] Then 색깔 = 파랑; If 이중파동[1] > 0 Then 이중파동 = 저[1]; Else { plot1(저[1],"Zigzag",blue); var2 = 저[1]; var3 = -1; } } If 추세[1] == 상승 && 추세 == 상승 && 저[1] > 기준저 && 기준저 * (1 + (상승률/100)) < Lbody Then { For j = 18 DownTo 1 { 고[j+1] = 고[j]; 고Bar[j+1] = 고Bar[j]; 저[j+1] = 저[j]; 저Bar[j+1] = 저Bar[j]; } 고[1] = 기준고; 고Bar[1] = 기준고Bar; 저[1] = 기준저; 저Bar[1] = 기준저Bar; 기준저 = Lbody; 기준저Bar = 0; 기준고 = Hbody; 기준고Bar = 0; If 고[2] < 고[1] Then 색깔 = 빨강; plot1(고[1],"Zigzag",RED); var1 = 고[1]; var3 = 1; If 저[2] > 저[1] Then 색깔 = 파랑; 이중파동 = 저[1]; } If 추세 == 양방향 Then { For j = 18 DownTo 1 { 고[j+1] = 고[j]; 고Bar[j+1] = 고Bar[j]; 저[j+1] = 저[j]; 저Bar[j+1] = 저Bar[j]; } 고[1] = 기준고; 고Bar[1] = 기준고Bar; 저[1] = 기준저; 저Bar[1] = 기준저Bar; 기준고 = Hbody; 기준고Bar = 0; 기준저 = Lbody; 기준저Bar = 0; 추세 = 추세[1]; If 추세[1] == 상승 Then { If 고[2] < 고[1] Then 색깔 = 빨강; Plot1(고[1],"Zigzag",RED); var1 = 고[1]; var3 = 1; If 저[2] > 저[1] Then 색깔 = 파랑; 이중파동 = 저[1]; } Else { If 저[2] > 저[1] Then 색깔 = 파랑; Plot1(저[1],"Zigzag",blue); Text_New(sdate,stime,저[1],NumToStr(저[1],2)); var2 = 저[1]; var3 = -1; If 고[2] < 고[1] Then 색깔 = 빨강; 이중파동 = 고[1]; } } if var3 == -1 Then{ plot2(var2); } if var3 == 1 Then{ plot2(var1); } ₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩ 첨 부 끝 ₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩₩ > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 부탁드립니다. > 안녕하세요 예스스탁입니다. 1. Input:chngRate(5); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0),TL2(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; } Condition1 = Min(valArr[1],valArr[2]) * (1 + (chngRate/100)) < H and lastHiVal < H; Condition2 = Max(valArr[1],valArr[2]) * (1 - (chngRate/100)) > L and (lastLoVal > L || lastLoVal == 0); If Condition1 Then { lastHiVal = H; lastLoVal = 0; } If Condition2 Then { lastLoVal = L; lastHiVal = 0; } turnPntBit = ""; If Condition1 and Condition2 Then { If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else If turnPntArr[1] == "Lo" Then turnPntBit = "Hi"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit == "Hi" or turnPntBit == "Lo" Then { If turnPntBit <> turnPntArr[1] Then { for j = 18 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then{ TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); TL2 = TL_New(sDate[barArr[4]],sTime[barArr[4]],valArr[4],sDate[barArr[2]],sTime[barArr[2]],valArr[2]); if turnPntArr[2] == "Hi" Then TL_SetColor(TL2,RED); Else TL_SetColor(TL2,blue); } Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); TL_SetColor(TL1,Black); 2 Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0),TL2(0), Text1(0),처리구분(""),T(0); Array:고점[10,2](0),저점[10,2](0); //가격,위치 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1], NumToStr(고점[1,1],2)); Text_SetStyle(Text1, 2, 1); } } If 처리구분 == "저점처리" Then { lastLoVal = L; If 저점[1,2] < 고점[1,2] then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1], NumToStr(저점[1,1],2)); Text_SetStyle(Text1, 2, 0); } } TL_SetSize(TL1,3); TL_SetColor(TL1,CYAN); If 처리구분 == "고점처리" Then T = 1; If 처리구분 == "저점처리" Then T = -1; if T == -1 and T[1] != -1 Then{ TL2 = TL_New(sDate[index-고점[2,2]],sTime[index-고점[2,2]],고점[2,1],sDate[index-고점[1,2]],sTime[index-고점[1,2]],고점[1,1]); TL_SetColor(TL2,red); } if T == 1 and T[1] != 1 Then{ TL2 = TL_New(sDate[index-저점[2,2]],sTime[index-저점[2,2]],저점[2,1],sDate[index-저점[1,2]],sTime[index-저점[1,2]],저점[1,1]); TL_SetColor(TL2,blue); } 즐거운 하루되세요 > 예시스 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 아래 두 식은 수식지왕님의 블로그에서 참조(주석생략)한 식인데요. 두 식 모두 고점과 저점을 수평선(Plot)으로 잇는 식을 부탁드립니다. 예전에 답해주셨던 게시물 내용을 참조로 스스로 식을 작성해 보았지만 아직 초보의 한계를 벗어나지 못하고 있네요. 잘 부탁드리며 항상 적극적인 도움을 주셔서 감사드립니다. 1번 식 #==========================================# # 지표명 : 지그재그파동(변동률) # 작성자 : 수식지왕 # 블로그 : http://yahoosir.blog.me #==========================================# Input:chngRate(5); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; Condition1 = Min(valArr[1],valArr[2]) * (1 + (chngRate/100)) < H and lastHiVal < H; Condition2 = Max(valArr[1],valArr[2]) * (1 - (chngRate/100)) > L and (lastLoVal > L || lastLoVal == 0); If Condition1 Then { lastHiVal = H; lastLoVal = 0; } If Condition2 Then { lastLoVal = L; lastHiVal = 0; } turnPntBit = ""; If Condition1 and Condition2 Then { If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else If turnPntArr[1] == "Lo" Then turnPntBit = "Hi"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit == "Hi" or turnPntBit == "Lo" Then { If turnPntBit <> turnPntArr[1] Then { for j = 18 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); TL_SetColor(TL1,Black); 2번 식 Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0), Text1(0),처리구분(""); Array:고점[10,2](0),저점[10,2](0); //가격,위치 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1], sDate[eBar],sTime[eBar],고점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1], NumToStr(고점[1,1],2)); Text_SetStyle(Text1, 2, 1); } } If 처리구분 == "저점처리" Then { lastLoVal = L; If 저점[1,2] < 고점[1,2] then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1], sDate[eBar],sTime[eBar],저점[1,1]); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1], NumToStr(저점[1,1],2)); Text_SetStyle(Text1, 2, 0); } } TL_SetSize(TL1,3); TL_SetColor(TL1,CYAN);