커뮤니티

수식 검토부탁드립니다.

프로필 이미지
파쿠3
2013-08-05 09:50:59
188
글번호 66066
답변완료
아래와 같은 수식을 5분 챠트를 열어놓고, 10분봉을 참조로 불러와 매매하는 시스템입니다. 여기서 문제는, 예를 들어 05:00에 들어가서 05:05 에 바로 청산이 될경우, 05:05에 다시 매수진입을 하고 있습니다. 진입신호가 아님에도 불구하고, 진입후 5분후 청산될 경우, 청산과 동시에 다시 진입을 합니다. 10분뿐만 아니라 다른봉을 참조해도 마찬가지 결과입니다. 코드 검토 및 수정을 부탁드립니다. input : CT(0); // CT(1)=양봉 O<C , CT(0)=음봉 O>C input : N(5); input : Zero(0); var : TF(0),OpenV(0),CloseV(0),cnt(0),sellcond(false); var : count11(0),count12(0),count21(0),count22(0),count31(0),count32(0); var : A1max(0),a2max(0); Array : D1[20](0),A1[20](0),D2[20](0),A2[20](0),CC[20](0),OO[20](0); TF = TimeToMinutes(stime)%10; if dayindex == 0 or (TF < TF[1] ) Then openV = O; CloseV = C; if TF == 5 Then{ if CloseV > OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = 1; A1[0] = abs(OpenV-CloseV); D2[0] = 1; A2[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; D2[cnt] = D1[cnt-1][1]; A2[cnt] = A1[cnt-1][1]; } } if CloseV < OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = -1; A1[0] = abs(OpenV-CloseV); D2[0] = -1; A2[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; D2[cnt] = D2[cnt-1][1]; A2[cnt] = A2[cnt-1][1]; } } if CloseV == OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = 0; A1[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; } } } sellcond = false; count11 = 0; count12 = 0; count21 = 0; count22 = 0; count31 = 0; count32 = 0; A1max = 0; A2max = 0; for cnt = 0 to N-1{ if D1[cnt] == 1 Then count11 = count11+1; if D1[cnt] == -1 Then count12 = count12+1; if D1[cnt] >= 0 Then count21 = count21+1; if D1[cnt] <= 0 Then count22 = count22+1; if D2[cnt] == 1 Then count31 = count31+1; if D2[cnt] == -1 Then count32 = count32+1; if A1[cnt] > A1max Then A1max = A1[cnt]; if A2[cnt] > A2max Then A2max = A2[cnt]; } if Zero == 0 Then{ if CT == 0 Then sellcond = count12 == N and A1[n-1] == A1max; if CT == 1 Then sellcond = count11 == N and A1[n-1] == A1max; } if Zero == 1 Then{ if CT == 0 Then sellcond = count22 == N and CC[N-1] < OO[N-1] and A1[n-1] == A1max; if CT == 1 Then sellcond = count21 == N and CC[N-1] > OO[N-1] and A1[n-1] == A1max; } if Zero == 2 Then{ if CT == 0 and count32 == N and A2[N-1] == A2max Then sellcond = true; if CT == 1 and count31 == N and A2[N-1] == A2max Then sellcond = true; } if sellcond == true Then buy("C", OnClose, DEF, 1); SetStopProfittarget(0.0012,PointStop); SetStopLoss(0.0040,PointStop);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2013-08-05 16:35:19

안녕하세요 예스스탁입니다. 진입자체는 현재봉의TF값이 0인지 5인지 구분하지 않습니다. 1. 청산봉에서는 진입신호가 발생하지 않게 하고자 하시면 아래식 이용하시면 됩니다. input : CT(0); // CT(1)=양봉 O<C , CT(0)=음봉 O>C input : N(5); input : Zero(0); var : TF(0),OpenV(0),CloseV(0),cnt(0),sellcond(false); var : count11(0),count12(0),count21(0),count22(0),count31(0),count32(0); var : A1max(0),a2max(0); Array : D1[20](0),A1[20](0),D2[20](0),A2[20](0),CC[20](0),OO[20](0); TF = TimeToMinutes(stime)%10; if dayindex == 0 or (TF < TF[1] ) Then{ openV = O; } CloseV = C; if TF == 5 Then{ if CloseV > OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = 1; A1[0] = abs(OpenV-CloseV); D2[0] = 1; A2[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; D2[cnt] = D1[cnt-1][1]; A2[cnt] = A1[cnt-1][1]; } } if CloseV < OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = -1; A1[0] = abs(OpenV-CloseV); D2[0] = -1; A2[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; D2[cnt] = D2[cnt-1][1]; A2[cnt] = A2[cnt-1][1]; } } if CloseV == OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = 0; A1[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; } } } sellcond = false; count11 = 0; count12 = 0; count21 = 0; count22 = 0; count31 = 0; count32 = 0; A1max = 0; A2max = 0; for cnt = 0 to N-1{ if D1[cnt] == 1 Then count11 = count11+1; if D1[cnt] == -1 Then count12 = count12+1; if D1[cnt] >= 0 Then count21 = count21+1; if D1[cnt] <= 0 Then count22 = count22+1; if D2[cnt] == 1 Then count31 = count31+1; if D2[cnt] == -1 Then count32 = count32+1; if A1[cnt] > A1max Then A1max = A1[cnt]; if A2[cnt] > A2max Then A2max = A2[cnt]; } if Zero == 0 Then{ if CT == 0 Then sellcond = count12 == N and A1[n-1] == A1max; if CT == 1 Then sellcond = count11 == N and A1[n-1] == A1max; } if Zero == 1 Then{ if CT == 0 Then sellcond = count22 == N and CC[N-1] < OO[N-1] and A1[n-1] == A1max; if CT == 1 Then sellcond = count21 == N and CC[N-1] > OO[N-1] and A1[n-1] == A1max; } if Zero == 2 Then{ if CT == 0 and count32 == N and A2[N-1] == A2max Then sellcond = true; if CT == 1 and count31 == N and A2[N-1] == A2max Then sellcond = true; } if (TotalTrades == 0 or (MarketPosition == 0 and BarsSinceExit(1) != 0)) and sellcond == true Then buy("C", OnClose, DEF, 1); SetStopProfittarget(0.0012,PointStop); SetStopLoss(0.0040,PointStop); 2. TF가 5일때만 진입하고자 하시면 아래와 같이 작성하시면 됩니다. input : CT(0); // CT(1)=양봉 O<C , CT(0)=음봉 O>C input : N(5); input : Zero(0); var : TF(0),OpenV(0),CloseV(0),cnt(0),sellcond(false); var : count11(0),count12(0),count21(0),count22(0),count31(0),count32(0); var : A1max(0),a2max(0); Array : D1[20](0),A1[20](0),D2[20](0),A2[20](0),CC[20](0),OO[20](0); TF = TimeToMinutes(stime)%10; if dayindex == 0 or (TF < TF[1] ) Then{ openV = O; } CloseV = C; if TF == 5 Then{ if CloseV > OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = 1; A1[0] = abs(OpenV-CloseV); D2[0] = 1; A2[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; D2[cnt] = D1[cnt-1][1]; A2[cnt] = A1[cnt-1][1]; } } if CloseV < OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = -1; A1[0] = abs(OpenV-CloseV); D2[0] = -1; A2[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; D2[cnt] = D2[cnt-1][1]; A2[cnt] = A2[cnt-1][1]; } } if CloseV == OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = 0; A1[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; } } } sellcond = false; count11 = 0; count12 = 0; count21 = 0; count22 = 0; count31 = 0; count32 = 0; A1max = 0; A2max = 0; for cnt = 0 to N-1{ if D1[cnt] == 1 Then count11 = count11+1; if D1[cnt] == -1 Then count12 = count12+1; if D1[cnt] >= 0 Then count21 = count21+1; if D1[cnt] <= 0 Then count22 = count22+1; if D2[cnt] == 1 Then count31 = count31+1; if D2[cnt] == -1 Then count32 = count32+1; if A1[cnt] > A1max Then A1max = A1[cnt]; if A2[cnt] > A2max Then A2max = A2[cnt]; } if Zero == 0 Then{ if CT == 0 Then sellcond = count12 == N and A1[n-1] == A1max; if CT == 1 Then sellcond = count11 == N and A1[n-1] == A1max; } if Zero == 1 Then{ if CT == 0 Then sellcond = count22 == N and CC[N-1] < OO[N-1] and A1[n-1] == A1max; if CT == 1 Then sellcond = count21 == N and CC[N-1] > OO[N-1] and A1[n-1] == A1max; } if Zero == 2 Then{ if CT == 0 and count32 == N and A2[N-1] == A2max Then sellcond = true; if CT == 1 and count31 == N and A2[N-1] == A2max Then sellcond = true; } if TF == 5 and sellcond == true Then buy("C", OnClose, DEF, 1); SetStopProfittarget(0.0012,PointStop); SetStopLoss(0.0040,PointStop); 즐거운 하루되세요 즐거운 하루되세요 > 파쿠3 님이 쓴 글입니다. > 제목 : 수식 검토부탁드립니다. > 아래와 같은 수식을 5분 챠트를 열어놓고, 10분봉을 참조로 불러와 매매하는 시스템입니다. 여기서 문제는, 예를 들어 05:00에 들어가서 05:05 에 바로 청산이 될경우, 05:05에 다시 매수진입을 하고 있습니다. 진입신호가 아님에도 불구하고, 진입후 5분후 청산될 경우, 청산과 동시에 다시 진입을 합니다. 10분뿐만 아니라 다른봉을 참조해도 마찬가지 결과입니다. 코드 검토 및 수정을 부탁드립니다. input : CT(0); // CT(1)=양봉 O<C , CT(0)=음봉 O>C input : N(5); input : Zero(0); var : TF(0),OpenV(0),CloseV(0),cnt(0),sellcond(false); var : count11(0),count12(0),count21(0),count22(0),count31(0),count32(0); var : A1max(0),a2max(0); Array : D1[20](0),A1[20](0),D2[20](0),A2[20](0),CC[20](0),OO[20](0); TF = TimeToMinutes(stime)%10; if dayindex == 0 or (TF < TF[1] ) Then openV = O; CloseV = C; if TF == 5 Then{ if CloseV > OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = 1; A1[0] = abs(OpenV-CloseV); D2[0] = 1; A2[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; D2[cnt] = D1[cnt-1][1]; A2[cnt] = A1[cnt-1][1]; } } if CloseV < OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = -1; A1[0] = abs(OpenV-CloseV); D2[0] = -1; A2[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; D2[cnt] = D2[cnt-1][1]; A2[cnt] = A2[cnt-1][1]; } } if CloseV == OpenV Then{ CC[0] = closeV; OO[0] = OpenV; D1[0] = 0; A1[0] = abs(OpenV-CloseV); for cnt = 1 to 19{ CC[cnt] = CC[cnt-1][1]; OO[cnt] = OO[cnt-1][1]; D1[cnt] = D1[cnt-1][1]; A1[cnt] = A1[cnt-1][1]; } } } sellcond = false; count11 = 0; count12 = 0; count21 = 0; count22 = 0; count31 = 0; count32 = 0; A1max = 0; A2max = 0; for cnt = 0 to N-1{ if D1[cnt] == 1 Then count11 = count11+1; if D1[cnt] == -1 Then count12 = count12+1; if D1[cnt] >= 0 Then count21 = count21+1; if D1[cnt] <= 0 Then count22 = count22+1; if D2[cnt] == 1 Then count31 = count31+1; if D2[cnt] == -1 Then count32 = count32+1; if A1[cnt] > A1max Then A1max = A1[cnt]; if A2[cnt] > A2max Then A2max = A2[cnt]; } if Zero == 0 Then{ if CT == 0 Then sellcond = count12 == N and A1[n-1] == A1max; if CT == 1 Then sellcond = count11 == N and A1[n-1] == A1max; } if Zero == 1 Then{ if CT == 0 Then sellcond = count22 == N and CC[N-1] < OO[N-1] and A1[n-1] == A1max; if CT == 1 Then sellcond = count21 == N and CC[N-1] > OO[N-1] and A1[n-1] == A1max; } if Zero == 2 Then{ if CT == 0 and count32 == N and A2[N-1] == A2max Then sellcond = true; if CT == 1 and count31 == N and A2[N-1] == A2max Then sellcond = true; } if sellcond == true Then buy("C", OnClose, DEF, 1); SetStopProfittarget(0.0012,PointStop); SetStopLoss(0.0040,PointStop);