커뮤니티

시스템식 부탁드립니다.

프로필 이미지
양치기
2015-07-22 07:16:26
152
글번호 88746
답변완료
항상 도움 주셔서 감사합니다. 문1) 아래와 같이 시스템식을 작성하였는데 매수만 되고 매도는 안됩니다. 또 청산식에 의해 청산이 안되고 당일청산만 됩니다. 시스템식 오류 수정 부탁드립니다. #==========================================# # 지표명 : 지그재그파동(기간값)-12 # 작성자 : 수식지왕 # 블로그 : http://yahoosir.blog.me #==========================================# Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); // 봉이 새로 생겼으므로 봉개수 관리하는 변수들의 봉개수 값 1씩 증가 For j = 0 To 19 { barArr[j] = barArr[j] + 1; } // 고점조건 = 현재 봉의 고가가 기간최고가이면서 최고가 갱신되었을 때; // 저점조건 = 현재 봉의 저가가 기간최저가이면서 최저가 갱신되었을 때; // 고점,저점조건 만족시 현재 봉의 고[저]가를 변수에 저장 Condition1 = Highest(H,length) == H and lastHiVal <> H; Condition2 = Lowest(L,length) == L and lastLoVal <> L; If Condition1 Then lastHiVal = H; If Condition2 Then lastLoVal = L; // 전환점구분 null값으로 초기화; // if 고점조건, 저점조건 동시 만족시 { // if 전환점배열의 현재(배열상 1번째)값이 고점이면 전환점구분 = 저점; // else if 전환점배열의 현재 값이 저점이면 전환점구분 = 고점; // else if 고점조건 만족하면 전환점구분 = 고점; // else if 저점조건 만족하면 전환점구분 = 저점; 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 전환점구분에 값이 있을 때만 then 아래 실행, 없으면 통과 // if 신규 전환점구분이 현재(전환점배열 1번째)와 다르면 then // 배열값들을 이전값으로 Move; 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 전환점구분이 바뀌었거나 또는 // (전환점구분은 안바뀌었는데 // (이전 고점보다 높은 고점이 발생했거나 또는 // 이전 저점보다 낮은 저점이 발생했으면)) then If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { // 값 배열에는 고점 또는 저점을 대입; // 봉개수 배열에는 0값 대입; // 전환점 배열에 전환점구분값을 대입; valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; // if 이전봉대비 전환점구분이 바뀌었다면 추세선 새로 그리고; // else 전환점구분이 안바뀌었으면 값만 바뀐거므로 추세선 연장; 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,4); TL_SetColor(TL1,GREEN); # 진입 체크 UpTL_chk = TL1[2] < TL1[1] and TL1[1] > TL1[0] ; # 상승꼭지점 DnTL_chk = TL1[2] > TL1[1] and TL1[1] < TL1[0] ; # 하락꼭지점 IF UpTL_chk == true Then { var1 = C[1] ; UpTL_chk = false; } IF DnTL_chk == true Then { var2 = C[1] ; DnTL_chk = false; } # 매수진입 IF C > var1 and TL1[0] > TL1[1] then { buy("buy", Atstop, C) ; } # 매도진입 IF C < var2 and TL1[0] < TL1[1] then { sell("sell", Atstop, C) ; } # 매수청산 IF Marketposition == 1 and UpTL_chk == true Then { ExitLong("BX1", AtStop, C); } # 매도청산 IF Marketposition == -1 and DnTL_chk == true Then { ExitShort("SX1", AtStop, C); } ##### 당일청산 ##### if stime == 050000 or (stime > 055000 and stime[1] < 050000) then { # 포지션 청산 exitlong("BDF"); exitshort("SDF"); } 문2) 지그재그 추세선 기간이(하나는 12,하나는 10) 다른것을 가지고 지그재그 추세선의 최고점이 일치 하는 곳에서 매수 최저점이 일치하는 곳에서 매도하는 시스템식 부탁드립니다. 청산은 짧은 기간(10)이 최고점이나 최저점이 꺽이는 지점에서 하고 싶습니다. 시스템식 도움 부탁드립니다.
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2015-07-22 15:47:52

안녕하세요 예스스탁입니다. 1. TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]); 에서 TL1에 저장되는 값은 추세선의 아이디 입니다. 추세선값이 아닙니다. TL_SetSize(TL1,4); TL_SetColor(TL1,GREEN); 위와 같이 TL1에 아이디를 저장해서 사이즈나 색상변경할때 아이디를 지정해지정하기 위함입니다. 추세선이 그려질때마다 예를 들어 1씩 증가합니다. 그러므로 작성하신 식에서 UpTL_chk = TL1[2] < TL1[1] and TL1[1] > TL1[0] ; # 상승꼭지점 DnTL_chk = TL1[2] > TL1[1] and TL1[1] < TL1[0] ; # 하락꼭지점 위 내용은 조건자체가 충족되지 않고 var1과 var2도 항상 0입니다 매수가 발생한것은 추세선은 발생할때마다 아이디가 1씩 증가를 하고 var1이 0이고 종가가 0보다는 항상 크기때문에 발생한것 뿐입니다. 해당식에서 고점과 저점이 판별되는 타이밍은 turnPntArr[1][0]변수입니다. 해당 변수의 값이 변경이 되면 추세의 전환이 판단이 되고 해당 고점과 저점에서 현재까지 추세선을 긋습니다. 즉 추세선은 후행적으로 그려집니다. 해당 내용 변경해서 작성한다면 아래 정도의 내용이 될것 같습니다. Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); var : UpTL_chk(false),DnTL_chk(false); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); // 봉이 새로 생겼으므로 봉개수 관리하는 변수들의 봉개수 값 1씩 증가 For j = 0 To 19 { barArr[j] = barArr[j] + 1; } // 고점조건 = 현재 봉의 고가가 기간최고가이면서 최고가 갱신되었을 때; // 저점조건 = 현재 봉의 저가가 기간최저가이면서 최저가 갱신되었을 때; // 고점,저점조건 만족시 현재 봉의 고[저]가를 변수에 저장 Condition1 = Highest(H,length) == H and lastHiVal <> H; Condition2 = Lowest(L,length) == L and lastLoVal <> L; If Condition1 Then lastHiVal = H; If Condition2 Then lastLoVal = L; // 전환점구분 null값으로 초기화; // if 고점조건, 저점조건 동시 만족시 { // if 전환점배열의 현재(배열상 1번째)값이 고점이면 전환점구분 = 저점; // else if 전환점배열의 현재 값이 저점이면 전환점구분 = 고점; // else if 고점조건 만족하면 전환점구분 = 고점; // else if 저점조건 만족하면 전환점구분 = 저점; 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 전환점구분에 값이 있을 때만 then 아래 실행, 없으면 통과 // if 신규 전환점구분이 현재(전환점배열 1번째)와 다르면 then // 배열값들을 이전값으로 Move; 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 전환점구분이 바뀌었거나 또는 // (전환점구분은 안바뀌었는데 // (이전 고점보다 높은 고점이 발생했거나 또는 // 이전 저점보다 낮은 저점이 발생했으면)) then If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { // 값 배열에는 고점 또는 저점을 대입; // 봉개수 배열에는 0값 대입; // 전환점 배열에 전환점구분값을 대입; valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; // if 이전봉대비 전환점구분이 바뀌었다면 추세선 새로 그리고; // else 전환점구분이 안바뀌었으면 값만 바뀐거므로 추세선 연장; 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,4); TL_SetColor(TL1,GREEN); # 진입 체크 TL_SetSize(TL1,4); TL_SetColor(TL1,GREEN); If turnPntArr[1][1] <> turnPntArr[1][0] and turnPntArr[1][0] == "Lo" Then var1 = valArr[2]; if turnPntArr[1][1] <> turnPntArr[1][0] and turnPntArr[1][0] == "Hi" Then var2 = valArr[2]; # 매수진입 IF turnPntArr[1][0] == "Hi" and C > var1 then { buy("buy") ; } # 매도진입 IF turnPntArr[1][0] == "Lo" and C < var2 then { sell("sell") ; } # 매수청산 IF Marketposition == 1 and turnPntArr[1][1] <> turnPntArr[1][0] and turnPntArr[1][0] == "Lo" Then { ExitLong("BX1"); } # 매도청산 IF Marketposition == -1 and turnPntArr[1][1] <> turnPntArr[1][0] and turnPntArr[1][0] == "Hi" Then { ExitShort("SX1"); } ##### 당일청산 ##### if stime == 050000 or (stime > 055000 and stime[1] < 050000) then { # 포지션 청산 exitlong("BDF"); exitshort("SDF"); } 2. Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); var : UpTL_chk(false),DnTL_chk(false); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); Input:length1(10); var:lastHiVal1(0),lastLoVal1(0),turnPntBit1(""),TL11(0); Array:valArr1[20](0),barArr1[20](0),turnPntArr1[20](""); For j = 0 To 19 { barArr[j] = barArr[j] + 1; } Condition1 = Highest(H,length) == H and lastHiVal <> H; Condition2 = Lowest(L,length) == L and lastLoVal <> L; If Condition1 Then lastHiVal = H; If Condition2 Then lastLoVal = L; 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,4); TL_SetColor(TL1,GREEN); # 진입 체크 TL_SetSize(TL1,4); TL_SetColor(TL1,GREEN); For j = 0 To 19 { barArr1[j] = barArr1[j] + 1; } Condition11 = Highest(H,length1) == H and lastHiVal1 <> H; Condition12 = Lowest(L,length1) == L and lastLoVal1 <> L; If Condition11 Then lastHiVal1 = H; If Condition12 Then lastLoVal1 = L; turnPntBit1 = ""; If Condition11 and Condition12 Then { If turnPntArr1[1] == "Hi" Then turnPntBit1 = "Lo"; Else If turnPntArr1[1] == "Lo" Then turnPntBit1 = "Hi"; } Else If Condition11 Then turnPntBit1 = "Hi"; Else If Condition12 Then turnPntBit1 = "Lo"; If turnPntBit1 == "Hi" or turnPntBit1 == "Lo" Then { If turnPntBit1 <> turnPntArr1[1] Then { for j = 18 downto 1 { valArr1[j+1] = valArr1[j]; barArr1[j+1] = barArr1[j]; turnPntArr1[j+1] = turnPntArr1[j]; } } If turnPntBit1 <> turnPntArr1[1] or (turnPntBit1 == turnPntArr1[1] and ((turnPntBit1 == "Hi" and valArr1[1] < H) or (turnPntBit1 == "Lo" and valArr1[1] > L))) Then { valArr1[1] = IFF(turnPntBit1 == "Hi",H,L); barArr1[1] = 0; turnPntArr1[1] = turnPntBit1; If turnPntArr1[1][1] <> turnPntArr1[1][0] Then TL11 = TL_New(sDate[barArr1[2]],sTime[barArr1[2]],valArr1[2],sDate[barArr1[1]],sTime[barArr1[1]],valArr1[1]); Else TL_SetEnd(TL11,sDate[barArr1[1]],sTime[barArr1[1]],valArr1[1]); } } TL_SetSize(TL11,4); TL_SetColor(TL11,GREEN); If turnPntArr[1][1] <> turnPntArr[1][0] and turnPntArr[1][0] == "Lo" Then var1 = valArr[2]; if turnPntArr[1][1] <> turnPntArr[1][0] and turnPntArr[1][0] == "Hi" Then var2 = valArr[2]; If turnPntArr1[1][1] <> turnPntArr1[1][0] and turnPntArr1[1][0] == "Lo" Then var11 = valArr1[2]; if turnPntArr1[1][1] <> turnPntArr1[1][0] and turnPntArr1[1][0] == "Hi" Then var22 = valArr1[2]; # 매수진입 IF var1 == var11 and var1[1] != var11[1] then buy("buy") ; # 매도진입 IF var2 == var22 and var2[1] != var22[1] then sell("sell") ; # 매수청산 IF Marketposition == 1 and turnPntArr1[1][1] <> turnPntArr1[1][0] and turnPntArr1[1][0] == "Lo" Then { ExitLong("BX11"); } # 매도청산 IF Marketposition == -1 and turnPntArr1[1][1] <> turnPntArr1[1][0] and turnPntArr1[1][0] == "Hi" Then { ExitShort("SX11"); } ##### 당일청산 ##### if stime == 050000 or (stime > 055000 and stime[1] < 050000) then { # 포지션 청산 exitlong("BDF1"); exitshort("SDF1"); } 즐거운 하루되세요 > 양치기 님이 쓴 글입니다. > 제목 : 시스템식 부탁드립니다. > 항상 도움 주셔서 감사합니다. 문1) 아래와 같이 시스템식을 작성하였는데 매수만 되고 매도는 안됩니다. 또 청산식에 의해 청산이 안되고 당일청산만 됩니다. 시스템식 오류 수정 부탁드립니다. #==========================================# # 지표명 : 지그재그파동(기간값)-12 # 작성자 : 수식지왕 # 블로그 : http://yahoosir.blog.me #==========================================# Input:length(12); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[20](0),barArr[20](0),turnPntArr[20](""); // 봉이 새로 생겼으므로 봉개수 관리하는 변수들의 봉개수 값 1씩 증가 For j = 0 To 19 { barArr[j] = barArr[j] + 1; } // 고점조건 = 현재 봉의 고가가 기간최고가이면서 최고가 갱신되었을 때; // 저점조건 = 현재 봉의 저가가 기간최저가이면서 최저가 갱신되었을 때; // 고점,저점조건 만족시 현재 봉의 고[저]가를 변수에 저장 Condition1 = Highest(H,length) == H and lastHiVal <> H; Condition2 = Lowest(L,length) == L and lastLoVal <> L; If Condition1 Then lastHiVal = H; If Condition2 Then lastLoVal = L; // 전환점구분 null값으로 초기화; // if 고점조건, 저점조건 동시 만족시 { // if 전환점배열의 현재(배열상 1번째)값이 고점이면 전환점구분 = 저점; // else if 전환점배열의 현재 값이 저점이면 전환점구분 = 고점; // else if 고점조건 만족하면 전환점구분 = 고점; // else if 저점조건 만족하면 전환점구분 = 저점; 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 전환점구분에 값이 있을 때만 then 아래 실행, 없으면 통과 // if 신규 전환점구분이 현재(전환점배열 1번째)와 다르면 then // 배열값들을 이전값으로 Move; 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 전환점구분이 바뀌었거나 또는 // (전환점구분은 안바뀌었는데 // (이전 고점보다 높은 고점이 발생했거나 또는 // 이전 저점보다 낮은 저점이 발생했으면)) then If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { // 값 배열에는 고점 또는 저점을 대입; // 봉개수 배열에는 0값 대입; // 전환점 배열에 전환점구분값을 대입; valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; // if 이전봉대비 전환점구분이 바뀌었다면 추세선 새로 그리고; // else 전환점구분이 안바뀌었으면 값만 바뀐거므로 추세선 연장; 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,4); TL_SetColor(TL1,GREEN); # 진입 체크 UpTL_chk = TL1[2] < TL1[1] and TL1[1] > TL1[0] ; # 상승꼭지점 DnTL_chk = TL1[2] > TL1[1] and TL1[1] < TL1[0] ; # 하락꼭지점 IF UpTL_chk == true Then { var1 = C[1] ; UpTL_chk = false; } IF DnTL_chk == true Then { var2 = C[1] ; DnTL_chk = false; } # 매수진입 IF C > var1 and TL1[0] > TL1[1] then { buy("buy", Atstop, C) ; } # 매도진입 IF C < var2 and TL1[0] < TL1[1] then { sell("sell", Atstop, C) ; } # 매수청산 IF Marketposition == 1 and UpTL_chk == true Then { ExitLong("BX1", AtStop, C); } # 매도청산 IF Marketposition == -1 and DnTL_chk == true Then { ExitShort("SX1", AtStop, C); } ##### 당일청산 ##### if stime == 050000 or (stime > 055000 and stime[1] < 050000) then { # 포지션 청산 exitlong("BDF"); exitshort("SDF"); } 문2) 지그재그 추세선 기간이(하나는 12,하나는 10) 다른것을 가지고 지그재그 추세선의 최고점이 일치 하는 곳에서 매수 최저점이 일치하는 곳에서 매도하는 시스템식 부탁드립니다. 청산은 짧은 기간(10)이 최고점이나 최저점이 꺽이는 지점에서 하고 싶습니다. 시스템식 도움 부탁드립니다.