커뮤니티
수식 검증 부탁드립니다.
2013-10-10 00:53:11
285
글번호 68270
안녕하세요. 수고가 많으시네요~
시스템 수식을 작성했는데 이게 원래 TS 전략인데 YT로 바꿔봤는데 제대로
바꿨는지 모르겠어서 검증 부탁드립니다.
전략은
1) 준비단계
a) MACD 함수를 이용하여 MACD값을 구한다.
b) MACD의 지수 이동 평균값을 구한다.
c) a)와 b)의 차이를 구한다. 이것을 MACD differential이라고 부른다.
d) MACD differential이 0을 상/하향 돌파하는 최근 4개의 순간을 찾는다.

2) 매수진입
준비 단계의 조건이 최근 50개의 봉 안에서 만족되고, 최근 4번의 상,하향 교차가 발생하는 봉의 최고가에 최근 4개봉의 ATR의 1/2를 더하고 이 값에 buy stop주문을 낸다.(돌파시 매수주문)

3) 매도진입
역시 같은 준비 단계의 조건하에, 최근 50개의 봉 안에서 만족되고, 최근 4번의 상,하향 교차가 발생하는 봉의 최저가에 최근 4개봉의 ATR의 1/2를 빼고 이 값에 sell stop주문을 낸다.(돌파시 매도주문)

4) 청산
최근의 6개 봉의 최저가를 기록하면 매수 청산, 최고가를 기록하면 매도 청산
이고 수식은 다음과 같습니다.
Input : shortma(12), longma(26), macdma(9), ncos(4), nbars(50), trailbar(6);
vars: mval(0), mavg(0), mdif(0), counter(0), totalbars(0), highesthi(0), lowestlo(0), lstopprice(0), sstopprice(0);
array: co[2,50](0);
mval=macd(shortma, longma);
mavg=ema(macd(shortma,longma),macdma);
mdif=mval-mavg
##array에 정보저장
if crossup(mdif,0) or crossdown(mdif,0) then {
for counter=0 to 49
co[0,50-counter]=co[0,49-counter];
co[1,50-counter]=co[1,49-counter];
co[2,50-counter]=co[2,49-counter];
co[0,0]=barindex;
co[1,0]=high;
co[2,0]=low;
##최고값, 최저값 찾기
highesthi=-1;
lowestlo=9999;
for counter=0 to ncos-1 Begin
if co[1,counter] > highesthi Then
highesthi=co[1, counter];
if co[2, counter] < lowestlo Then
lowestlo=co[2, counter];
end;
##매매
totalbars=barindex-co[0,ncos-1];
if totalbars < nbars then {
buy("b", atstop, highesthi+atr(4)*0.5, 0);
sell("s", atstop, lowestlo-atr(4)*0.5, 0);
}
##trailing stop
if marketposition == 1 then {
lstopprice=lowest(l,trailbar);
exitlong("longstop",atlimit,lstopprice);
}
if marketposition == -1 then {
sstopprice=highest(h,trailbar);
exitshort("shortstop",atlimit,sstopprice);
}
이상한 부분은 수정부탁드립니다.
감사합니다~
답변 1
예스스탁 예스스탁 답변
2013-10-10 17:38:44
안녕하세요
예스스탁입니다.
수정한 식입니다.
Input : shortma(12), longma(26), macdma(9), ncos(4), nbars(50), trailbar(6);
vars: mval(0), mavg(0), mdif(0), cnt(0), totalbars(0), highesthi(0), lowestlo(0), lstopprice(0), sstopprice(0);
array: crossH[50](0),crossL[50](0);
mval=macd(shortma, longma);
mavg=ema(mval,macdma);
mdif=mval-mavg;
##array에 정보저장
if crossup(mdif,0) or crossdown(mdif,0) then {
CrossH[0] = H;
crossL[0] = L;
for cnt = 1 to 49{
crossH[cnt] = CrossH[cnt-1][1];
crossL[cnt] = CrossL[cnt-1][1];
}
}
##최고값, 최저값 찾기
highesthi = -1;
lowestlo = 9999999999;
for cnt = 0 to ncos-1 {
if CrossH[cnt] > highesthi Then
highesthi = crossH[cnt];
if crossL[cnt] < lowestlo Then
lowestlo = crossL[cnt];
}
##매매
if countif(crossup(mdif,0) or crossdown(mdif,0),50) >= 4 then {
buy("b", atstop, highesthi+atr(4)*0.5);
sell("s", atstop, lowestlo-atr(4)*0.5);
}
##trailing stop
if marketposition == 1 then {
lstopprice=lowest(l,trailbar);
exitlong("longstop",AtStop,lstopprice);
}
if marketposition == -1 then {
sstopprice=highest(h,trailbar);
exitshort("shortstop",AtStop,sstopprice);
}
즐거운 하루되세요
> jacobs 님이 쓴 글입니다.
> 제목 : 수식 검증 부탁드립니다.
> 안녕하세요. 수고가 많으시네요~
시스템 수식을 작성했는데 이게 원래 TS 전략인데 YT로 바꿔봤는데 제대로
바꿨는지 모르겠어서 검증 부탁드립니다.
전략은
1) 준비단계
a) MACD 함수를 이용하여 MACD값을 구한다.
b) MACD의 지수 이동 평균값을 구한다.
c) a)와 b)의 차이를 구한다. 이것을 MACD differential이라고 부른다.
d) MACD differential이 0을 상/하향 돌파하는 최근 4개의 순간을 찾는다.

2) 매수진입
준비 단계의 조건이 최근 50개의 봉 안에서 만족되고, 최근 4번의 상,하향 교차가 발생하는 봉의 최고가에 최근 4개봉의 ATR의 1/2를 더하고 이 값에 buy stop주문을 낸다.(돌파시 매수주문)

3) 매도진입
역시 같은 준비 단계의 조건하에, 최근 50개의 봉 안에서 만족되고, 최근 4번의 상,하향 교차가 발생하는 봉의 최저가에 최근 4개봉의 ATR의 1/2를 빼고 이 값에 sell stop주문을 낸다.(돌파시 매도주문)

4) 청산
최근의 6개 봉의 최저가를 기록하면 매수 청산, 최고가를 기록하면 매도 청산
이고 수식은 다음과 같습니다.
Input : shortma(12), longma(26), macdma(9), ncos(4), nbars(50), trailbar(6);
vars: mval(0), mavg(0), mdif(0), counter(0), totalbars(0), highesthi(0), lowestlo(0), lstopprice(0), sstopprice(0);
array: co[2,50](0);
mval=macd(shortma, longma);
mavg=ema(macd(shortma,longma),macdma);
mdif=mval-mavg
##array에 정보저장
if crossup(mdif,0) or crossdown(mdif,0) then {
for counter=0 to 49
co[0,50-counter]=co[0,49-counter];
co[1,50-counter]=co[1,49-counter];
co[2,50-counter]=co[2,49-counter];
co[0,0]=barindex;
co[1,0]=high;
co[2,0]=low;
##최고값, 최저값 찾기
highesthi=-1;
lowestlo=9999;
for counter=0 to ncos-1 Begin
if co[1,counter] > highesthi Then
highesthi=co[1, counter];
if co[2, counter] < lowestlo Then
lowestlo=co[2, counter];
end;
##매매
totalbars=barindex-co[0,ncos-1];
if totalbars < nbars then {
buy("b", atstop, highesthi+atr(4)*0.5, 0);
sell("s", atstop, lowestlo-atr(4)*0.5, 0);
}
##trailing stop
if marketposition == 1 then {
lstopprice=lowest(l,trailbar);
exitlong("longstop",atlimit,lstopprice);
}
if marketposition == -1 then {
sstopprice=highest(h,trailbar);
exitshort("shortstop",atlimit,sstopprice);
}
이상한 부분은 수정부탁드립니다.
감사합니다~
다음글
이전글