커뮤니티

수식 수정을 부탁드립니다

프로필 이미지
뽄때
2014-06-15 21:25:12
136
글번호 75842
답변완료
항상 도움을 주셔서 감사를드립니다. 아래의 식 중에서 주봉, 일봉, 챠트의 분봉, 타분봉1, 타분봉2의 스톡케스틱을 단순 스토케스틱으로 수정을 부탁드립니다. ============================================================================= Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); var : dhighVal(0), dlowVal(0), dFK(0), dSK(0), dSD(0); var : dEp1(0), dEp2(0),dPreSK(0), dPreSD(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 dhighVal = dayhigh(0); dlowVal = daylow(0); for cnt = 0 to Period-1 { if dayHigh(cnt) > dhighVal then dhighVal = dayhigh(cnt); if dayLow(cnt) < dlowVal then dlowVal = dayLow(cnt); } #Fast StochasticsK dFK = (C-dlowVal)/(dhighVal-dlowVal)*100; #Slow StochasticsK / Slow StochasticsD dEp1 = 2/(Period1+1); dEp2 = 2/(Period2+1); if date != date[1] then { dPreSK = dSK[1]; dPreSD = dSD[1]; } dSK = dFK * dEP1 + dPreSK * (1-dEP1); dSD = dSK * dEP2 + dPreSD * (1-dEP2); #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 일봉이 상승중이고, 240분봉이 %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(nSK1[0],25) Then{ BuySetup = true; } if nSK1[0] >= 60 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true and crossup(stok,20) Then{ BuySetup2 = true; Dncnt = 0; } #%k가 60이상 상승하면 BuySetup2은 false if stok >= 60 Then BuySetup2 = false; #BuySetup2이 true일때 if BuySetup2 == true Then{ #데드크로스가 발생하면 횟수 저장 if CrossDown(stok,stod) and stok[1] > stod[1] Then Dncnt = Dncnt+1; #매수조건 if Dncnt == 1 and crossup(stok,stod) and stok[1] < stod[1] and MarketPosition == 0 and dSK > dSD Then buy("1차매수",OnClose,def,수량1); }
시스템
답변 4
프로필 이미지

예스스탁 예스스탁 답변

2014-06-16 17:01:43

안녕하세요 예스스탁입니다. 다른 주기는 모두 단순이평으로 되어 있습니다. 일봉만 지수이평으로 되어 있어 단순이평으로 수정했습니다. Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); Array : dHH[50](0),dLL[50](0),dFK1[50](0),dSK1[50](0),dSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); var : dHvalue1(0),dLvalue1(0),dsum1(0),dsum2(0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 if date != date[1] Then{ dHH[0] = H; dLL[0] = L; for cnt = 1 to 49{ dHH[cnt] = dHH[cnt-1][1]; dLL[cnt] = dLL[cnt-1][1]; dFK1[cnt] = dFK1[cnt-1][1]; dSK1[cnt] = dSK1[cnt-1][1]; dSD1[cnt] = dSD1[cnt-1][1]; } } if H > dHH[0] Then dHH[0] = H; if L < dLL[0] Then dLL[0] = L; if dHH[StoPeriod] > 0 Then{ dHvalue1 = dHH[0]; dLvalue1 = dLL[0]; for cnt = 0 to StoPeriod-1 { if dHH[cnt] > dHvalue1 then dHvalue1 = dHH[cnt]; if dLL[cnt] < dLvalue1 then dLvalue1 = dLL[cnt]; } dFK1[0] = (C-dLvalue1)/(dHvalue1-dLvalue1)*100; } if dFK1[StoPeriod1] > 0 Then{ dsum1 = 0; for cnt = 0 to StoPeriod1-1{ dsum1 = dsum1+dFK1[cnt]; } dSK1[0] = dsum1/StoPeriod1; } if dSK1[StoPeriod2] > 0 Then{ dsum2 = 0; for cnt = 0 to StoPeriod2-1{ dsum2 = dsum2+wSK1[cnt]; } dSD1[0] = dsum2/StoPeriod2; } #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 일봉이 상승중이고, 240분봉이 %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(nSK1[0],25) Then{ BuySetup = true; } if nSK1[0] >= 60 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true and crossup(stok,20) Then{ BuySetup2 = true; Dncnt = 0; } #%k가 60이상 상승하면 BuySetup2은 false if stok >= 60 Then BuySetup2 = false; #BuySetup2이 true일때 if BuySetup2 == true Then{ #데드크로스가 발생하면 횟수 저장 if CrossDown(stok,stod) and stok[1] > stod[1] Then Dncnt = Dncnt+1; #매수조건 if Dncnt == 1 and crossup(stok,stod) and stok[1] < stod[1] and MarketPosition == 0 and dSK1[0] > dSD1[0] Then buy("1차매수",OnClose,def,수량1); } 즐거운 하루되세요 > 뽄때 님이 쓴 글입니다. > 제목 : 수식 수정을 부탁드립니다 > 항상 도움을 주셔서 감사를드립니다. 아래의 식 중에서 주봉, 일봉, 챠트의 분봉, 타분봉1, 타분봉2의 스톡케스틱을 단순 스토케스틱으로 수정을 부탁드립니다. ============================================================================= Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); var : dhighVal(0), dlowVal(0), dFK(0), dSK(0), dSD(0); var : dEp1(0), dEp2(0),dPreSK(0), dPreSD(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 dhighVal = dayhigh(0); dlowVal = daylow(0); for cnt = 0 to Period-1 { if dayHigh(cnt) > dhighVal then dhighVal = dayhigh(cnt); if dayLow(cnt) < dlowVal then dlowVal = dayLow(cnt); } #Fast StochasticsK dFK = (C-dlowVal)/(dhighVal-dlowVal)*100; #Slow StochasticsK / Slow StochasticsD dEp1 = 2/(Period1+1); dEp2 = 2/(Period2+1); if date != date[1] then { dPreSK = dSK[1]; dPreSD = dSD[1]; } dSK = dFK * dEP1 + dPreSK * (1-dEP1); dSD = dSK * dEP2 + dPreSD * (1-dEP2); #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 일봉이 상승중이고, 240분봉이 %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(nSK1[0],25) Then{ BuySetup = true; } if nSK1[0] >= 60 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true and crossup(stok,20) Then{ BuySetup2 = true; Dncnt = 0; } #%k가 60이상 상승하면 BuySetup2은 false if stok >= 60 Then BuySetup2 = false; #BuySetup2이 true일때 if BuySetup2 == true Then{ #데드크로스가 발생하면 횟수 저장 if CrossDown(stok,stod) and stok[1] > stod[1] Then Dncnt = Dncnt+1; #매수조건 if Dncnt == 1 and crossup(stok,stod) and stok[1] < stod[1] and MarketPosition == 0 and dSK > dSD Then buy("1차매수",OnClose,def,수량1); }
프로필 이미지

뽄때

2014-06-17 08:51:38

수정하여 주신식을 시스템에 적용해 보니 일봉의 스톡케스틱이 데드크로스 구간에서도 매수일어납니다 (dSK1[0] < dSD1[0]) 그리고 매도포지션을 추가하였더니 아예 시스템이 불통입니다 일봉의 수식을 다시 한 번 검토부탁드립니다 ------------------ 시스템에 적용하여 본 식------------------------------------- Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); Array : dHH[50](0),dLL[50](0),dFK1[50](0),dSK1[50](0),dSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); var : dHvalue1(0),dLvalue1(0),dsum1(0),dsum2(0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 if date != date[1] Then{ dHH[0] = H; dLL[0] = L; for cnt = 1 to 49{ dHH[cnt] = dHH[cnt-1][1]; dLL[cnt] = dLL[cnt-1][1]; dFK1[cnt] = dFK1[cnt-1][1]; dSK1[cnt] = dSK1[cnt-1][1]; dSD1[cnt] = dSD1[cnt-1][1]; } } if H > dHH[0] Then dHH[0] = H; if L < dLL[0] Then dLL[0] = L; if dHH[StoPeriod] > 0 Then{ dHvalue1 = dHH[0]; dLvalue1 = dLL[0]; for cnt = 0 to StoPeriod-1 { if dHH[cnt] > dHvalue1 then dHvalue1 = dHH[cnt]; if dLL[cnt] < dLvalue1 then dLvalue1 = dLL[cnt]; } dFK1[0] = (C-dLvalue1)/(dHvalue1-dLvalue1)*100; } if dFK1[StoPeriod1] > 0 Then{ dsum1 = 0; for cnt = 0 to StoPeriod1-1{ dsum1 = dsum1+dFK1[cnt]; } dSK1[0] = dsum1/StoPeriod1; } if dSK1[StoPeriod2] > 0 Then{ dsum2 = 0; for cnt = 0 to StoPeriod2-1{ dsum2 = dsum2+wSK1[cnt]; } dSD1[0] = dsum2/StoPeriod2; } #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 매수포지션 진입============================================ # %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(stok,25) Then{ BuySetup = true; } #%k가 60이상 상승하면 BuySetup은 false if stok >= 80 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true Then{ #매수조건 : 스톡케스틱 골든크로스 and 일봉 골든크로스 구간 if crossup(stok,stod) and stok[1] < stod[1] and dSK1[0] > dSD1[0] and MarketPosition == 0 Then buy("1차매수",OnClose,def,수량1); } ##매수청산 if MarketPosition == 1 Then{ #매수포지션에 진입하면 BuySetup은 false BuySetup = false; #80을 상향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossUp(stok,80) Then ExitSetup1 = true; if ExitSetup1 == true and CrossDown(stok,stod) and stok[1] > stod[1] Then ExitLong("매수청산"); } # 매도포지션 진입============================================ # %k가 80을 상향돌파하면 SellSetup은 true if SellSetup == false and CrossUp(stok,80) Then{ SellSetup = true; } #%k가 40이하 하락하면 SellSetup은 false if stok <= 40 Then SellSetup = false; #SellSetup이 true일때 if SellSetup == true Then{ #매도조건 : 스톡케스틱 데드크로스 and 일봉 데드크로스 구간 if CrossDown(stok,stod) and stok[1] > stod[1] and dSK1[0] < dSD1[0] and MarketPosition == 0 Then Sell("1차매도",OnClose,def,수량1); } ##매도 포지션 청산 if MarketPosition == -1 Then{ #매도포지션에 진입하면 SellSetup은 false SellSetup = false; #20을 하향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossDown(stok,20) Then ExitSetup2 = true; if ExitSetup2 == true and CrossUp(stok,stod) and stok[1] < stod[1] Then ExitShort("매도청산"); } Else{ ExitSetup1 = false; ExitSetup2 = false; ExitSetup3 = false; ExitSetup4 = false; }
프로필 이미지

예스스탁 예스스탁 답변

2014-06-17 14:14:08

안녕하세요 예스스탁입니다. 식을 수정했습니다. 일봉스토케스틱의 변수가 잘못할당&#46124;습니다. 아래식 다시 적용해 보시기 바랍니다. Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); Array : dHH[50](0),dLL[50](0),dFK1[50](0),dSK1[50](0),dSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); var : dHvalue1(0),dLvalue1(0),dsum1(0),dsum2(0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 if date != date[1] Then{ dHH[0] = H; dLL[0] = L; for cnt = 1 to 49{ dHH[cnt] = dHH[cnt-1][1]; dLL[cnt] = dLL[cnt-1][1]; dFK1[cnt] = dFK1[cnt-1][1]; dSK1[cnt] = dSK1[cnt-1][1]; dSD1[cnt] = dSD1[cnt-1][1]; } } if H > dHH[0] Then dHH[0] = H; if L < dLL[0] Then dLL[0] = L; if dHH[StoPeriod] > 0 Then{ dHvalue1 = dHH[0]; dLvalue1 = dLL[0]; for cnt = 0 to StoPeriod-1 { if dHH[cnt] > dHvalue1 then dHvalue1 = dHH[cnt]; if dLL[cnt] < dLvalue1 then dLvalue1 = dLL[cnt]; } dFK1[0] = (C-dLvalue1)/(dHvalue1-dLvalue1)*100; } if dFK1[StoPeriod1] > 0 Then{ dsum1 = 0; for cnt = 0 to StoPeriod1-1{ dsum1 = dsum1+dFK1[cnt]; } dSK1[0] = dsum1/StoPeriod1; } if dSK1[StoPeriod2] > 0 Then{ dsum2 = 0; for cnt = 0 to StoPeriod2-1{ dsum2 = dsum2+dSK1[cnt]; } dSD1[0] = dsum2/StoPeriod2; } #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 매수포지션 진입============================================ # %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(stok,25) Then{ BuySetup = true; } #%k가 60이상 상승하면 BuySetup은 false if stok >= 80 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true Then{ #매수조건 : 스톡케스틱 골든크로스 and 일봉 골든크로스 구간 if crossup(stok,stod) and stok[1] < stod[1] and dSK1[0] > dSD1[0] and MarketPosition == 0 Then buy("1차매수",OnClose,def,수량1); } ##매수청산 if MarketPosition == 1 Then{ #매수포지션에 진입하면 BuySetup은 false BuySetup = false; #80을 상향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossUp(stok,80) Then ExitSetup1 = true; if ExitSetup1 == true and CrossDown(stok,stod) and stok[1] > stod[1] Then ExitLong("매수청산"); } # 매도포지션 진입============================================ # %k가 80을 상향돌파하면 SellSetup은 true if SellSetup == false and CrossUp(stok,80) Then{ SellSetup = true; } #%k가 40이하 하락하면 SellSetup은 false if stok <= 40 Then SellSetup = false; #SellSetup이 true일때 if SellSetup == true Then{ #매도조건 : 스톡케스틱 데드크로스 and 일봉 데드크로스 구간 if CrossDown(stok,stod) and stok[1] > stod[1] and dSK1[0] < dSD1[0] and MarketPosition == 0 Then Sell("1차매도",OnClose,def,수량1); } ##매도 포지션 청산 if MarketPosition == -1 Then{ #매도포지션에 진입하면 SellSetup은 false SellSetup = false; #20을 하향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossDown(stok,20) Then ExitSetup2 = true; if ExitSetup2 == true and CrossUp(stok,stod) and stok[1] < stod[1] Then ExitShort("매도청산"); } Else{ ExitSetup1 = false; ExitSetup2 = false; ExitSetup3 = false; ExitSetup4 = false; } 즐거운 하루되세요 > 뽄때 님이 쓴 글입니다. > 제목 : Re : Re : 수식 수정을 부탁드립니다 > 수정하여 주신식을 시스템에 적용해 보니 일봉의 스톡케스틱이 데드크로스 구간에서도 매수일어납니다 (dSK1[0] < dSD1[0]) 그리고 매도포지션을 추가하였더니 아예 시스템이 불통입니다 일봉의 수식을 다시 한 번 검토부탁드립니다 ------------------ 시스템에 적용하여 본 식------------------------------------- Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); Array : dHH[50](0),dLL[50](0),dFK1[50](0),dSK1[50](0),dSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); var : dHvalue1(0),dLvalue1(0),dsum1(0),dsum2(0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 if date != date[1] Then{ dHH[0] = H; dLL[0] = L; for cnt = 1 to 49{ dHH[cnt] = dHH[cnt-1][1]; dLL[cnt] = dLL[cnt-1][1]; dFK1[cnt] = dFK1[cnt-1][1]; dSK1[cnt] = dSK1[cnt-1][1]; dSD1[cnt] = dSD1[cnt-1][1]; } } if H > dHH[0] Then dHH[0] = H; if L < dLL[0] Then dLL[0] = L; if dHH[StoPeriod] > 0 Then{ dHvalue1 = dHH[0]; dLvalue1 = dLL[0]; for cnt = 0 to StoPeriod-1 { if dHH[cnt] > dHvalue1 then dHvalue1 = dHH[cnt]; if dLL[cnt] < dLvalue1 then dLvalue1 = dLL[cnt]; } dFK1[0] = (C-dLvalue1)/(dHvalue1-dLvalue1)*100; } if dFK1[StoPeriod1] > 0 Then{ dsum1 = 0; for cnt = 0 to StoPeriod1-1{ dsum1 = dsum1+dFK1[cnt]; } dSK1[0] = dsum1/StoPeriod1; } if dSK1[StoPeriod2] > 0 Then{ dsum2 = 0; for cnt = 0 to StoPeriod2-1{ dsum2 = dsum2+wSK1[cnt]; } dSD1[0] = dsum2/StoPeriod2; } #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 매수포지션 진입============================================ # %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(stok,25) Then{ BuySetup = true; } #%k가 60이상 상승하면 BuySetup은 false if stok >= 80 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true Then{ #매수조건 : 스톡케스틱 골든크로스 and 일봉 골든크로스 구간 if crossup(stok,stod) and stok[1] < stod[1] and dSK1[0] > dSD1[0] and MarketPosition == 0 Then buy("1차매수",OnClose,def,수량1); } ##매수청산 if MarketPosition == 1 Then{ #매수포지션에 진입하면 BuySetup은 false BuySetup = false; #80을 상향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossUp(stok,80) Then ExitSetup1 = true; if ExitSetup1 == true and CrossDown(stok,stod) and stok[1] > stod[1] Then ExitLong("매수청산"); } # 매도포지션 진입============================================ # %k가 80을 상향돌파하면 SellSetup은 true if SellSetup == false and CrossUp(stok,80) Then{ SellSetup = true; } #%k가 40이하 하락하면 SellSetup은 false if stok <= 40 Then SellSetup = false; #SellSetup이 true일때 if SellSetup == true Then{ #매도조건 : 스톡케스틱 데드크로스 and 일봉 데드크로스 구간 if CrossDown(stok,stod) and stok[1] > stod[1] and dSK1[0] < dSD1[0] and MarketPosition == 0 Then Sell("1차매도",OnClose,def,수량1); } ##매도 포지션 청산 if MarketPosition == -1 Then{ #매도포지션에 진입하면 SellSetup은 false SellSetup = false; #20을 하향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossDown(stok,20) Then ExitSetup2 = true; if ExitSetup2 == true and CrossUp(stok,stod) and stok[1] < stod[1] Then ExitShort("매도청산"); } Else{ ExitSetup1 = false; ExitSetup2 = false; ExitSetup3 = false; ExitSetup4 = false; }
프로필 이미지

예스스탁 예스스탁 답변

2014-06-17 15:50:56

안녕하세요 예스스탁입니다. 매수청산에 사용되는 변수가 매도포지션이 아니면(무포나 매수포지션이면) false로 값을 만들라는 내용이 있어 모든 청산이 발생하지 않았습니다. Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); Array : dHH[50](0),dLL[50](0),dFK1[50](0),dSK1[50](0),dSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); var : dHvalue1(0),dLvalue1(0),dsum1(0),dsum2(0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 if date != date[1] Then{ dHH[0] = H; dLL[0] = L; for cnt = 1 to 49{ dHH[cnt] = dHH[cnt-1][1]; dLL[cnt] = dLL[cnt-1][1]; dFK1[cnt] = dFK1[cnt-1][1]; dSK1[cnt] = dSK1[cnt-1][1]; dSD1[cnt] = dSD1[cnt-1][1]; } } if H > dHH[0] Then dHH[0] = H; if L < dLL[0] Then dLL[0] = L; if dHH[StoPeriod] > 0 Then{ dHvalue1 = dHH[0]; dLvalue1 = dLL[0]; for cnt = 0 to StoPeriod-1 { if dHH[cnt] > dHvalue1 then dHvalue1 = dHH[cnt]; if dLL[cnt] < dLvalue1 then dLvalue1 = dLL[cnt]; } dFK1[0] = (C-dLvalue1)/(dHvalue1-dLvalue1)*100; } if dFK1[StoPeriod1] > 0 Then{ dsum1 = 0; for cnt = 0 to StoPeriod1-1{ dsum1 = dsum1+dFK1[cnt]; } dSK1[0] = dsum1/StoPeriod1; } if dSK1[StoPeriod2] > 0 Then{ dsum2 = 0; for cnt = 0 to StoPeriod2-1{ dsum2 = dsum2+dSK1[cnt]; } dSD1[0] = dsum2/StoPeriod2; } #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 매수포지션 진입============================================ # %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(stok,25) Then{ BuySetup = true; } #%k가 60이상 상승하면 BuySetup은 false if stok >= 80 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true Then{ #매수조건 : 스톡케스틱 골든크로스 and 일봉 골든크로스 구간 if crossup(stok,stod) and stok[1] < stod[1] and dSK1[0] > dSD1[0] and MarketPosition == 0 Then buy("1차매수",OnClose,def,수량1); } ##매수청산 if MarketPosition == 1 Then{ #매수포지션에 진입하면 BuySetup은 false BuySetup = false; #80을 상향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossUp(stok,80) Then ExitSetup1 = true; if ExitSetup1 == true and CrossDown(stok,stod) and stok[1] > stod[1] Then ExitLong("매수청산"); } Else //매수포지션이 아니면 ExitSetup1을 false로 초기화 ExitSetup1 = false; # 매도포지션 진입============================================ # %k가 80을 상향돌파하면 SellSetup은 true if SellSetup == false and CrossUp(stok,80) Then{ SellSetup = true; } #%k가 40이하 하락하면 SellSetup은 false if stok <= 40 Then SellSetup = false; #SellSetup이 true일때 if SellSetup == true Then{ #매도조건 : 스톡케스틱 데드크로스 and 일봉 데드크로스 구간 if CrossDown(stok,stod) and stok[1] > stod[1] and dSK1[0] < dSD1[0] and MarketPosition == 0 Then Sell("1차매도",OnClose,def,수량1); } ##매도 포지션 청산 if MarketPosition == -1 Then{ #매도포지션에 진입하면 SellSetup은 false SellSetup = false; #20을 하향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossDown(stok,20) Then ExitSetup2 = true; if ExitSetup2 == true and CrossUp(stok,stod) and stok[1] < stod[1] Then ExitShort("매도청산"); } Else{ //매도포지션이 아니면 ExitSetup2를 false로 초기화 ExitSetup2 = false; } 즐거운 하루되세요 > 예스스탁 님이 쓴 글입니다. > 제목 : Re : Re : Re : 수식 수정을 부탁드립니다 > 안녕하세요 예스스탁입니다. 식을 수정했습니다. 일봉스토케스틱의 변수가 잘못할당&#46124;습니다. 아래식 다시 적용해 보시기 바랍니다. Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); Array : dHH[50](0),dLL[50](0),dFK1[50](0),dSK1[50](0),dSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); var : dHvalue1(0),dLvalue1(0),dsum1(0),dsum2(0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 if date != date[1] Then{ dHH[0] = H; dLL[0] = L; for cnt = 1 to 49{ dHH[cnt] = dHH[cnt-1][1]; dLL[cnt] = dLL[cnt-1][1]; dFK1[cnt] = dFK1[cnt-1][1]; dSK1[cnt] = dSK1[cnt-1][1]; dSD1[cnt] = dSD1[cnt-1][1]; } } if H > dHH[0] Then dHH[0] = H; if L < dLL[0] Then dLL[0] = L; if dHH[StoPeriod] > 0 Then{ dHvalue1 = dHH[0]; dLvalue1 = dLL[0]; for cnt = 0 to StoPeriod-1 { if dHH[cnt] > dHvalue1 then dHvalue1 = dHH[cnt]; if dLL[cnt] < dLvalue1 then dLvalue1 = dLL[cnt]; } dFK1[0] = (C-dLvalue1)/(dHvalue1-dLvalue1)*100; } if dFK1[StoPeriod1] > 0 Then{ dsum1 = 0; for cnt = 0 to StoPeriod1-1{ dsum1 = dsum1+dFK1[cnt]; } dSK1[0] = dsum1/StoPeriod1; } if dSK1[StoPeriod2] > 0 Then{ dsum2 = 0; for cnt = 0 to StoPeriod2-1{ dsum2 = dsum2+dSK1[cnt]; } dSD1[0] = dsum2/StoPeriod2; } #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 매수포지션 진입============================================ # %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(stok,25) Then{ BuySetup = true; } #%k가 60이상 상승하면 BuySetup은 false if stok >= 80 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true Then{ #매수조건 : 스톡케스틱 골든크로스 and 일봉 골든크로스 구간 if crossup(stok,stod) and stok[1] < stod[1] and dSK1[0] > dSD1[0] and MarketPosition == 0 Then buy("1차매수",OnClose,def,수량1); } ##매수청산 if MarketPosition == 1 Then{ #매수포지션에 진입하면 BuySetup은 false BuySetup = false; #80을 상향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossUp(stok,80) Then ExitSetup1 = true; if ExitSetup1 == true and CrossDown(stok,stod) and stok[1] > stod[1] Then ExitLong("매수청산"); } # 매도포지션 진입============================================ # %k가 80을 상향돌파하면 SellSetup은 true if SellSetup == false and CrossUp(stok,80) Then{ SellSetup = true; } #%k가 40이하 하락하면 SellSetup은 false if stok <= 40 Then SellSetup = false; #SellSetup이 true일때 if SellSetup == true Then{ #매도조건 : 스톡케스틱 데드크로스 and 일봉 데드크로스 구간 if CrossDown(stok,stod) and stok[1] > stod[1] and dSK1[0] < dSD1[0] and MarketPosition == 0 Then Sell("1차매도",OnClose,def,수량1); } ##매도 포지션 청산 if MarketPosition == -1 Then{ #매도포지션에 진입하면 SellSetup은 false SellSetup = false; #20을 하향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossDown(stok,20) Then ExitSetup2 = true; if ExitSetup2 == true and CrossUp(stok,stod) and stok[1] < stod[1] Then ExitShort("매도청산"); } Else{ ExitSetup1 = false; ExitSetup2 = false; ExitSetup3 = false; ExitSetup4 = false; } 즐거운 하루되세요 > 뽄때 님이 쓴 글입니다. > 제목 : Re : Re : 수식 수정을 부탁드립니다 > 수정하여 주신식을 시스템에 적용해 보니 일봉의 스톡케스틱이 데드크로스 구간에서도 매수일어납니다 (dSK1[0] < dSD1[0]) 그리고 매도포지션을 추가하였더니 아예 시스템이 불통입니다 일봉의 수식을 다시 한 번 검토부탁드립니다 ------------------ 시스템에 적용하여 본 식------------------------------------- Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2); input : Atime1(240),Atime2(30),StoPeriod(25), StoPeriod1(6), StoPeriod2(6); var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0),Gncnt(0); Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),BuySetup2(true),SellSetup(true),SellSetup2(true),ExitSetup1(false),ExitSetup2(false),ExitSetup3(false),ExitSetup4(false); var : cnt(0),TF(0),Hvalue1(0), Lvalue1(0),sum1(0),sum2(0); Array : HH[50](0),LL[50](0),FK1[50](0),SK1[50](0),SD1[50](0); var : wHvalue1(0),wLvalue1(0),wsum1(0),wsum2(0); Array : WHH[50](0),WLL[50](0),wFK1[50](0),wSK1[50](0),wSD1[50](0); Array : dHH[50](0),dLL[50](0),dFK1[50](0),dSK1[50](0),dSD1[50](0); var : nTF(0),nHvalue1(0),nLvalue1(0),nsum1(0),nsum2(0); Array : nHH[50](0),nLL[50](0),nFK1[50](0),nSK1[50](0),nSD1[50](0); var : dHvalue1(0),dLvalue1(0),dsum1(0),dsum2(0); #주봉 스토케스틱 if DayOfWeek(sdate) < DayOfWeek(sdate[1]) Then{ wHH[0] = H; wLL[0] = L; for cnt = 1 to 49{ wHH[cnt] = wHH[cnt-1][1]; wLL[cnt] = wLL[cnt-1][1]; wFK1[cnt] = wFK1[cnt-1][1]; wSK1[cnt] = wSK1[cnt-1][1]; wSD1[cnt] = wSD1[cnt-1][1]; } } if H > wHH[0] Then wHH[0] = H; if L < wLL[0] Then wLL[0] = L; if wHH[StoPeriod] > 0 Then{ wHvalue1 = wHH[0]; wLvalue1 = wLL[0]; for cnt = 0 to StoPeriod-1 { if wHH[cnt] > wHvalue1 then wHvalue1 = wHH[cnt]; if wLL[cnt] < wLvalue1 then wLvalue1 = wLL[cnt]; } wFK1[0] = (C-wLvalue1)/(wHvalue1-wLvalue1)*100; } if wFK1[StoPeriod1] > 0 Then{ wsum1 = 0; for cnt = 0 to StoPeriod1-1{ wsum1 = wsum1+wFK1[cnt]; } wSK1[0] = wsum1/StoPeriod1; } if wSK1[StoPeriod2] > 0 Then{ wsum2 = 0; for cnt = 0 to StoPeriod2-1{ wsum2 = wsum2+wSK1[cnt]; } wSD1[0] = wsum2/StoPeriod2; } #일봉 스토케스틱 #N일간 최고가 및 최저가 if date != date[1] Then{ dHH[0] = H; dLL[0] = L; for cnt = 1 to 49{ dHH[cnt] = dHH[cnt-1][1]; dLL[cnt] = dLL[cnt-1][1]; dFK1[cnt] = dFK1[cnt-1][1]; dSK1[cnt] = dSK1[cnt-1][1]; dSD1[cnt] = dSD1[cnt-1][1]; } } if H > dHH[0] Then dHH[0] = H; if L < dLL[0] Then dLL[0] = L; if dHH[StoPeriod] > 0 Then{ dHvalue1 = dHH[0]; dLvalue1 = dLL[0]; for cnt = 0 to StoPeriod-1 { if dHH[cnt] > dHvalue1 then dHvalue1 = dHH[cnt]; if dLL[cnt] < dLvalue1 then dLvalue1 = dLL[cnt]; } dFK1[0] = (C-dLvalue1)/(dHvalue1-dLvalue1)*100; } if dFK1[StoPeriod1] > 0 Then{ dsum1 = 0; for cnt = 0 to StoPeriod1-1{ dsum1 = dsum1+dFK1[cnt]; } dSK1[0] = dsum1/StoPeriod1; } if dSK1[StoPeriod2] > 0 Then{ dsum2 = 0; for cnt = 0 to StoPeriod2-1{ dsum2 = dsum2+wSK1[cnt]; } dSD1[0] = dsum2/StoPeriod2; } #차트의 스토케스틱 Lvalue = lowest(L,Period); Hvalue = highest(H,period); FK = (Close - Lvalue) / (Hvalue - Lvalue) * 100; StoK = ma(FK,Period1); StoD = ma(StoK,Period2); mav = ma(C,MAP); #타분봉1 스토케스틱 TF = TimeToMinutes(stime)%Atime1; if dayindex == 0 or (TF < TF[1] and stime > stime[1]) Then{ HH[0] = H; LL[0] = L; for cnt = 1 to 49{ HH[cnt] = HH[cnt-1][1]; LL[cnt] = LL[cnt-1][1]; FK1[cnt] = FK1[cnt-1][1]; SK1[cnt] = SK1[cnt-1][1]; SD1[cnt] = SD1[cnt-1][1]; } } if H > HH[0] Then HH[0] = H; if L < LL[0] Then LL[0] = L; if HH[StoPeriod] > 0 Then{ Hvalue1 = HH[0]; Lvalue1 = LL[0]; for cnt = 0 to StoPeriod-1 { if HH[cnt] > Hvalue1 then Hvalue1 = HH[cnt]; if LL[cnt] < Lvalue1 then Lvalue1 = LL[cnt]; } FK1[0] = (C-Lvalue1)/(Hvalue1-Lvalue1)*100; } if FK1[StoPeriod1] > 0 Then{ sum1 = 0; for cnt = 0 to StoPeriod1-1{ sum1 = sum1+FK1[cnt]; } SK1[0] = sum1/StoPeriod1; } if SK1[StoPeriod2] > 0 Then{ sum2 = 0; for cnt = 0 to StoPeriod2-1{ sum2 = sum2+SK1[cnt]; } SD1[0] = sum2/StoPeriod2; } #타분봉2 스토케스틱 nTF = TimeToMinutes(stime)%Atime2; if dayindex == 0 or (nTF < nTF[1] and stime > stime[1]) Then{ nHH[0] = H; nLL[0] = L; for cnt = 1 to 49{ nHH[cnt] = nHH[cnt-1][1]; nLL[cnt] = nLL[cnt-1][1]; nFK1[cnt] = nFK1[cnt-1][1]; nSK1[cnt] = nSK1[cnt-1][1]; nSD1[cnt] = nSD1[cnt-1][1]; } } if H > nHH[0] Then nHH[0] = H; if L < nLL[0] Then nLL[0] = L; if nHH[StoPeriod] > 0 Then{ nHvalue1 = nHH[0]; nLvalue1 = nLL[0]; for cnt = 0 to StoPeriod-1 { if nHH[cnt] > nHvalue1 then nHvalue1 = nHH[cnt]; if nLL[cnt] < nLvalue1 then nLvalue1 = nLL[cnt]; } nFK1[0] = (C-nLvalue1)/(nHvalue1-nLvalue1)*100; } if nFK1[StoPeriod1] > 0 Then{ nsum1 = 0; for cnt = 0 to StoPeriod1-1{ nsum1 = nsum1+nFK1[cnt]; } nSK1[0] = nsum1/StoPeriod1; } if nSK1[StoPeriod2] > 0 Then{ nsum2 = 0; for cnt = 0 to StoPeriod2-1{ nsum2 = nsum2+nSK1[cnt]; } nSD1[0] = nsum2/StoPeriod2; } # 매수포지션 진입============================================ # %k가 25을 하향돌파하면 BuySetup은 true if BuySetup == false and CrossDown(stok,25) Then{ BuySetup = true; } #%k가 60이상 상승하면 BuySetup은 false if stok >= 80 Then BuySetup = false; #BuySetup이 true일때 if BuySetup == true Then{ #매수조건 : 스톡케스틱 골든크로스 and 일봉 골든크로스 구간 if crossup(stok,stod) and stok[1] < stod[1] and dSK1[0] > dSD1[0] and MarketPosition == 0 Then buy("1차매수",OnClose,def,수량1); } ##매수청산 if MarketPosition == 1 Then{ #매수포지션에 진입하면 BuySetup은 false BuySetup = false; #80을 상향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossUp(stok,80) Then ExitSetup1 = true; if ExitSetup1 == true and CrossDown(stok,stod) and stok[1] > stod[1] Then ExitLong("매수청산"); } # 매도포지션 진입============================================ # %k가 80을 상향돌파하면 SellSetup은 true if SellSetup == false and CrossUp(stok,80) Then{ SellSetup = true; } #%k가 40이하 하락하면 SellSetup은 false if stok <= 40 Then SellSetup = false; #SellSetup이 true일때 if SellSetup == true Then{ #매도조건 : 스톡케스틱 데드크로스 and 일봉 데드크로스 구간 if CrossDown(stok,stod) and stok[1] > stod[1] and dSK1[0] < dSD1[0] and MarketPosition == 0 Then Sell("1차매도",OnClose,def,수량1); } ##매도 포지션 청산 if MarketPosition == -1 Then{ #매도포지션에 진입하면 SellSetup은 false SellSetup = false; #20을 하향돌파한 이후에 첫번째 D.C 발생시 청산 if CrossDown(stok,20) Then ExitSetup2 = true; if ExitSetup2 == true and CrossUp(stok,stod) and stok[1] < stod[1] Then ExitShort("매도청산"); } Else{ ExitSetup1 = false; ExitSetup2 = false; ExitSetup3 = false; ExitSetup4 = false; }