커뮤니티
수식검토 부탁드립니다
2014-05-20 15:36:21
173
글번호 75238
매수포지션에서는 시스템결과가 정상적으로 나오는데,,, 매도포지션으로
수식을 수정하였는데 시스템결과가 나오질 않네요.. 검토좀 부탁드립니다
Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2);
input : Atime(60),StoPeriod(25), StoPeriod1(6), StoPeriod2(6);//타분봉(Atime) 스토케스틱
var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0);
Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),SellSetup(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);
#주봉 스토케스틱
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);
#타분봉 스토케스틱
TF = TimeToMinutes(stime)%Atime;
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;
}
#%k가 75을 상향돌파하면 SellSetup은 true
if SellSetup == false and CrossUP(stok,75) Then{
SellSetup = true;
}
#%k가 60이상 하락하면 SellSetup은 false
if Stok <= 60 Then
SellSetup = false;
#날짜와 시간 설정
if sdate > 19990101 and stime > 090000 Then
Condition1 = true;
#SellSetup이 true일때
if SellSetup == true Then{
#매도조건
if Condition1 == true and
CrossDown(stok,stod) and
stok[1] > stod[1] and
MarketPosition == 0 and
SK1[0] < SD1[0] and
dSK < dSD and
wSK1[0] < wSD1[0] and wSD1[0] < 100
Then
Sell("1차매도",OnClose,def,수량1);
}
## 추가매수 및 포지션 정리
if MarketPosition == 1 Then{
#매수포지션에 진입하면 SellSetup은 false
SellSetup = false;
#첫매도가에서 1POINT 상승하면 추가매수
if MaxEntries == 1 Then
Sell("2차매수",AtLimit,EntryPrice+1.0,수량2) ;
#추가매수후 첫진입가에서 3 POINT 하락하면 전량청산
if CurrentEntries == 2 Then
ExitShort("손절",AtStop,EntryPrice+3);
# 청산조건
if CrossUP(stok,25) Then
ExitShort("매도");
#목표수익
#진입1회
if MaxEntries == 1 Then
ExitShort("목표수익1",Atlimit,EntryPrice-1.0);
#진입2회
if MaxEntries == 2 Then
ExitShort("목표수익2",Atlimit,avgEntryPrice-0.5);
}
Else{
ExitSetup1 = false;
ExitSetup2 = false;
ExitSetup3 = false;
ExitSetup4 = false;
}
답변 3
예스스탁 예스스탁 답변
2014-05-20 16:29:00
안녕하세요
예스스탁입니다.
아래지표식을 적용해 보시면
해당 차트에서 지표값이 모두 0으로만 나오면
해당 분봉차트에서 주봉의 스토케스틱을 계산할만한
봉수가 되지 않는다는 내용입니다.
차트에 있는 봉으로만 계산을 하므로
해당 부분은 따로 처리가 되지 않습니다.
지표값이 출려되는데 신호가 발생하지 않는것은
지정한 진입조건이 모두 총족되는 봉이 없기 때문입니다.
Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2);
input : Atime(60),StoPeriod(25), StoPeriod1(6), StoPeriod2(6);//타분봉(Atime) 스토케스틱
var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0);
Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),SellSetup(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);
#주봉 스토케스틱
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);
#타분봉 스토케스틱
TF = TimeToMinutes(stime)%Atime;
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;
}
#%k가 75을 상향돌파하면 SellSetup은 true
if SellSetup == false and CrossUP(stok,75) Then{
SellSetup = true;
}
#%k가 60이상 하락하면 SellSetup은 false
if Stok <= 60 Then
SellSetup = false;
#날짜와 시간 설정
if sdate > 19990101 and stime > 090000 Then
Condition1 = true;
plot1(Wsk1[0]);
plot2(Wsd1[0]);
즐거운 하루되세요
> 뽄때 님이 쓴 글입니다.
> 제목 : 수식검토 부탁드립니다
> 매수포지션에서는 시스템결과가 정상적으로 나오는데,,, 매도포지션으로
수식을 수정하였는데 시스템결과가 나오질 않네요.. 검토좀 부탁드립니다
Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2);
input : Atime(60),StoPeriod(25), StoPeriod1(6), StoPeriod2(6);//타분봉(Atime) 스토케스틱
var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0);
Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),SellSetup(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);
#주봉 스토케스틱
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);
#타분봉 스토케스틱
TF = TimeToMinutes(stime)%Atime;
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;
}
#%k가 75을 상향돌파하면 SellSetup은 true
if SellSetup == false and CrossUP(stok,75) Then{
SellSetup = true;
}
#%k가 60이상 하락하면 SellSetup은 false
if Stok <= 60 Then
SellSetup = false;
#날짜와 시간 설정
if sdate > 19990101 and stime > 090000 Then
Condition1 = true;
#SellSetup이 true일때
if SellSetup == true Then{
#매도조건
if Condition1 == true and
CrossDown(stok,stod) and
stok[1] > stod[1] and
MarketPosition == 0 and
SK1[0] < SD1[0] and
dSK < dSD and
wSK1[0] < wSD1[0] and wSD1[0] < 100
Then
Sell("1차매도",OnClose,def,수량1);
}
## 추가매수 및 포지션 정리
if MarketPosition == 1 Then{
#매수포지션에 진입하면 SellSetup은 false
SellSetup = false;
#첫매도가에서 1POINT 상승하면 추가매수
if MaxEntries == 1 Then
Sell("2차매수",AtLimit,EntryPrice+1.0,수량2) ;
#추가매수후 첫진입가에서 3 POINT 하락하면 전량청산
if CurrentEntries == 2 Then
ExitShort("손절",AtStop,EntryPrice+3);
# 청산조건
if CrossUP(stok,25) Then
ExitShort("매도");
#목표수익
#진입1회
if MaxEntries == 1 Then
ExitShort("목표수익1",Atlimit,EntryPrice-1.0);
#진입2회
if MaxEntries == 2 Then
ExitShort("목표수익2",Atlimit,avgEntryPrice-0.5);
}
Else{
ExitSetup1 = false;
ExitSetup2 = false;
ExitSetup3 = false;
ExitSetup4 = false;
}
뽄때
2014-05-20 22:12:20
동일한 챠트에 단순히 매수진입만 즉 buy로 매수하고 exitlong로 정리하면
정상적으로 시스템이 작동하는데요.. sell식이 잘못된 거 아닌가요?
sell 조건:
주봉의 스톡케스틱 %k < %D 이고, 일봉의 스톡케스틱 %k < %D 이고, 타분봉 참조의 스톡케스틱 %k < %D 일때 챠트분봉의 %K가 75를 넘게된후 데드크로스가 발생하면 Sell
청산조건 :
챠트분봉의 %k값이 25선을 상향돌파하면 청산
수식 검토좀 부탁드립니다. 똑같은 조건으로 buy식은 되는데 Sell식을 시스템결과가 나올질 않네요..
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 수식검토 부탁드립니다
> 안녕하세요
예스스탁입니다.
아래지표식을 적용해 보시면
해당 차트에서 지표값이 모두 0으로만 나오면
해당 분봉차트에서 주봉의 스토케스틱을 계산할만한
봉수가 되지 않는다는 내용입니다.
차트에 있는 봉으로만 계산을 하므로
해당 부분은 따로 처리가 되지 않습니다.
지표값이 출려되는데 신호가 발생하지 않는것은
지정한 진입조건이 모두 총족되는 봉이 없기 때문입니다.
Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2);
input : Atime(60),StoPeriod(25), StoPeriod1(6), StoPeriod2(6);//타분봉(Atime) 스토케스틱
var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0);
Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),SellSetup(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);
#주봉 스토케스틱
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);
#타분봉 스토케스틱
TF = TimeToMinutes(stime)%Atime;
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;
}
#%k가 75을 상향돌파하면 SellSetup은 true
if SellSetup == false and CrossUP(stok,75) Then{
SellSetup = true;
}
#%k가 60이상 하락하면 SellSetup은 false
if Stok <= 60 Then
SellSetup = false;
#날짜와 시간 설정
if sdate > 19990101 and stime > 090000 Then
Condition1 = true;
plot1(Wsk1[0]);
plot2(Wsd1[0]);
즐거운 하루되세요
> 뽄때 님이 쓴 글입니다.
> 제목 : 수식검토 부탁드립니다
> 매수포지션에서는 시스템결과가 정상적으로 나오는데,,, 매도포지션으로
수식을 수정하였는데 시스템결과가 나오질 않네요.. 검토좀 부탁드립니다
Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2);
input : Atime(60),StoPeriod(25), StoPeriod1(6), StoPeriod2(6);//타분봉(Atime) 스토케스틱
var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0);
Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),SellSetup(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);
#주봉 스토케스틱
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);
#타분봉 스토케스틱
TF = TimeToMinutes(stime)%Atime;
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;
}
#%k가 75을 상향돌파하면 SellSetup은 true
if SellSetup == false and CrossUP(stok,75) Then{
SellSetup = true;
}
#%k가 60이상 하락하면 SellSetup은 false
if Stok <= 60 Then
SellSetup = false;
#날짜와 시간 설정
if sdate > 19990101 and stime > 090000 Then
Condition1 = true;
#SellSetup이 true일때
if SellSetup == true Then{
#매도조건
if Condition1 == true and
CrossDown(stok,stod) and
stok[1] > stod[1] and
MarketPosition == 0 and
SK1[0] < SD1[0] and
dSK < dSD and
wSK1[0] < wSD1[0] and wSD1[0] < 100
Then
Sell("1차매도",OnClose,def,수량1);
}
## 추가매수 및 포지션 정리
if MarketPosition == 1 Then{
#매수포지션에 진입하면 SellSetup은 false
SellSetup = false;
#첫매도가에서 1POINT 상승하면 추가매수
if MaxEntries == 1 Then
Sell("2차매수",AtLimit,EntryPrice+1.0,수량2) ;
#추가매수후 첫진입가에서 3 POINT 하락하면 전량청산
if CurrentEntries == 2 Then
ExitShort("손절",AtStop,EntryPrice+3);
# 청산조건
if CrossUP(stok,25) Then
ExitShort("매도");
#목표수익
#진입1회
if MaxEntries == 1 Then
ExitShort("목표수익1",Atlimit,EntryPrice-1.0);
#진입2회
if MaxEntries == 2 Then
ExitShort("목표수익2",Atlimit,avgEntryPrice-0.5);
}
Else{
ExitSetup1 = false;
ExitSetup2 = false;
ExitSetup3 = false;
ExitSetup4 = false;
}
예스스탁 예스스탁 답변
2014-05-21 11:06:22
> 뽄때 님이 쓴 글입니다.
> 제목 : Re : Re : 수식검토 부탁드립니다
> 동일한 챠트에 단순히 매수진입만 즉 buy로 매수하고 exitlong로 정리하면
정상적으로 시스템이 작동하는데요.. sell식이 잘못된 거 아닌가요?
sell 조건:
주봉의 스톡케스틱 %k < %D 이고, 일봉의 스톡케스틱 %k < %D 이고, 타분봉 참조의 스톡케스틱 %k < %D 일때 챠트분봉의 %K가 75를 넘게된후 데드크로스가 발생하면 Sell
청산조건 :
챠트분봉의 %k값이 25선을 상향돌파하면 청산
수식 검토좀 부탁드립니다. 똑같은 조건으로 buy식은 되는데 Sell식을 시스템결과가 나올질 않네요..
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 수식검토 부탁드립니다
> 안녕하세요
예스스탁입니다.
아래지표식을 적용해 보시면
해당 차트에서 지표값이 모두 0으로만 나오면
해당 분봉차트에서 주봉의 스토케스틱을 계산할만한
봉수가 되지 않는다는 내용입니다.
차트에 있는 봉으로만 계산을 하므로
해당 부분은 따로 처리가 되지 않습니다.
지표값이 출려되는데 신호가 발생하지 않는것은
지정한 진입조건이 모두 총족되는 봉이 없기 때문입니다.
Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2);
input : Atime(60),StoPeriod(25), StoPeriod1(6), StoPeriod2(6);//타분봉(Atime) 스토케스틱
var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0);
Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),SellSetup(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);
#주봉 스토케스틱
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);
#타분봉 스토케스틱
TF = TimeToMinutes(stime)%Atime;
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;
}
#%k가 75을 상향돌파하면 SellSetup은 true
if SellSetup == false and CrossUP(stok,75) Then{
SellSetup = true;
}
#%k가 60이상 하락하면 SellSetup은 false
if Stok <= 60 Then
SellSetup = false;
#날짜와 시간 설정
if sdate > 19990101 and stime > 090000 Then
Condition1 = true;
plot1(Wsk1[0]);
plot2(Wsd1[0]);
즐거운 하루되세요
> 뽄때 님이 쓴 글입니다.
> 제목 : 수식검토 부탁드립니다
> 매수포지션에서는 시스템결과가 정상적으로 나오는데,,, 매도포지션으로
수식을 수정하였는데 시스템결과가 나오질 않네요.. 검토좀 부탁드립니다
Input : Period(25), Period1(6), Period2(6), MAP(5),수량1(1),수량2(2);
input : Atime(60),StoPeriod(25), StoPeriod1(6), StoPeriod2(6);//타분봉(Atime) 스토케스틱
var : StoK(0),StoD(0),vol1(0),vol2(0),mav(0),SH(0),cross(0),Dncnt(0);
Var : Lvalue(0), Hvalue(0),FK(0),BuySetup(true),SellSetup(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);
#주봉 스토케스틱
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);
#타분봉 스토케스틱
TF = TimeToMinutes(stime)%Atime;
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;
}
#%k가 75을 상향돌파하면 SellSetup은 true
if SellSetup == false and CrossUP(stok,75) Then{
SellSetup = true;
}
#%k가 60이상 하락하면 SellSetup은 false
if Stok <= 60 Then
SellSetup = false;
#날짜와 시간 설정
if sdate > 19990101 and stime > 090000 Then
Condition1 = true;
#SellSetup이 true일때
if SellSetup == true Then{
#매도조건
if Condition1 == true and
CrossDown(stok,stod) and
stok[1] > stod[1] and
MarketPosition == 0 and
SK1[0] < SD1[0] and
dSK < dSD and
wSK1[0] < wSD1[0] and wSD1[0] < 100
Then
Sell("1차매도",OnClose,def,수량1);
}
## 추가매수 및 포지션 정리
if MarketPosition == 1 Then{
#매수포지션에 진입하면 SellSetup은 false
SellSetup = false;
#첫매도가에서 1POINT 상승하면 추가매수
if MaxEntries == 1 Then
Sell("2차매수",AtLimit,EntryPrice+1.0,수량2) ;
#추가매수후 첫진입가에서 3 POINT 하락하면 전량청산
if CurrentEntries == 2 Then
ExitShort("손절",AtStop,EntryPrice+3);
# 청산조건
if CrossUP(stok,25) Then
ExitShort("매도");
#목표수익
#진입1회
if MaxEntries == 1 Then
ExitShort("목표수익1",Atlimit,EntryPrice-1.0);
#진입2회
if MaxEntries == 2 Then
ExitShort("목표수익2",Atlimit,avgEntryPrice-0.5);
}
Else{
ExitSetup1 = false;
ExitSetup2 = false;
ExitSetup3 = false;
ExitSetup4 = false;
}
다음글
이전글