커뮤니티
수식 문의
2006-03-07 22:20:52
1172
글번호 9558
아래식은 분챠트를 기준으로 cci가 100 이상이면 매수하고 -100 이하면 매도하여 이평이 크로스되면 각각 청산하는 식으로 만들어 보았습니다
또 각각의 청산시 손절과 최대수익대비하락을 정하여 보았습니다
1. 아래식이 정확하게 작성되었는지 검토를 부탁드리며(아래와 같이 iff(c<entryprice()-0.3 , 1, 0) 과 setstoploss(0.3, pointstop)은 동일한 것인지 알고 싶습니다)
2. 아래의 수식에 기존의 수식틀은 유지하면서 '추가'로
"손절매가 2번 발생시 그날의 매매는 하지 않는다"와
"2번 연속으로 손절매가 발생할시 다음번 진입신호때에는 평소의 1계약이 아닌 2계약으로 진입한다"는 조건을 더하려면 어떻게 해야 하는지 도와 주십시오(연속 매수/도 신호인 경우와 그렇지 않을 경우를 구분하여 부탁드립니다.)
감사합니다
Input : P1(5), p2(20), p3(60);//이평변수
input: p4(17);//cci
var:value1(0), value2(0), value3(0), value4(0);
Var: buycond(0), exitlongcond(0), sellcond(0),exitshortcond(0);//매매상황
value1 = ma(C,p1);
value2 = ma(C,p2);
value3 = ma(C,p3);
value4 = cci(p4);
Buycond = //매수
iff(value4>100, 1, 0) &&
iff (time>092000 && time<144000, 1, 0);
exitlongcond=//매수청산
iff((Crossdown (value1, value2)), 1, 0);
if marketposition()==1 then{
iff (c<entryprice()-0.2, 1, 0);
setstoptrailing(0.3, 0.6, pointstop);
}
sellcond=//매도
iff(value4<-100, 1, 0)&&
iff (time>092000 && time<144000, 1, 0);
exitshortcond=//매도청산
iff((crossup (value1, value2)),1, 0);
if marketposition()==-1 then{
setstoploss(0.3, pointstop);
SetStopTrailing(0.4, 0.8, pointstop) ;
}
if buycond then
Buy();
if exitlongcond then
Exitlong();
if sellcond then
Sell();
if exitshortcond then
Exitshort();
답변 1
예스스탁 예스스탁 답변
2006-03-09 10:09:05
안녕하세요
예스스탁입니다.
1.
iff(c<entryprice()-0.3 , 1, 0) 와 setstoploss(0.3, pointstop)는
내용은 주가가 진입가-0.3이하로 떨어지면 손절하는 식이지만
iff(c<entryprice()-0.3 , 1, 0)같은 경우 봉이 완성후에 종가에 주문이 발생하므로
setstoploss(0.3, pointstop)는 주가가 진입가-0.3에 도달하는 즉시 주문이 발생합니다.
식을 수정했습니다.
iff(c<entryprice()-0.3 , 1, 0)와 같은 표현은 c < entryprice()-0.3같이 풀어서 작성하셔도 됩니다.
Input : P1(5), p2(20), p3(60); //이평변수
input: p4(17); //cci
var:value1(0), value2(0), value3(0), value4(0);
Var: buycond(0), exitlongcond(0), sellcond(0),exitshortcond(0); //매매상황
value1 = ma(C,p1);
value2 = ma(C,p2);
value3 = ma(C,p3);
value4 = cci(p4);
//매수
Buycond = value4 > 100 && stime > 92000 && stime < 144000;
//매수청산
exitlongcond= Crossdown(value1,value2);
//매도
sellcond= value4 < -100 && stime > 92000 && stime < 144000;
//매도청산
exitshortcond= crossup(value1, value2);
##손절
##트레일링스탑
if marketposition()==1 then{
setstoploss(0.2, pointstop);
setstoptrailing(0.3, 0.6, pointstop);
}
else if marketposition() == -1 then{
setstoploss(0.3, pointstop);
SetStopTrailing(0.4, 0.8, pointstop) ;
}
else
{
setstoploss(0, pointstop);
SetStopTrailing(0,0);
}
if marketposition() == 0 and buycond then
Buy();
if marketposition() == 1 and exitlongcond then
Exitlong();
if marketposition() == 0 and sellcond then
Sell();
if marketposition() == -1 and exitshortcond then
Exitshort();
2.
손절매 함수나 atstop으로 작성시 해당 손절매 부분만 정확히 제어하기 어렵습니다.
손절매를 종가로 진입으로 변경하여 작성했습니다.
[당일 손절매 2번시 매매정지]
Input : P1(5), p2(20), p3(60); //이평변수
input : p4(17); //cci
var : value1(0), value2(0), value3(0), value4(0),cnt(0);
Var : buycond(0), exitlongcond(0), sellcond(0),exitshortcond(0); //매매상황
value1 = ma(C,p1);
value2 = ma(C,p2);
value3 = ma(C,p3);
value4 = cci(p4);
//매수
Buycond = value4 > 100 && stime > 92000 && stime < 144000;
//매수청산
exitlongcond= Crossdown(value1,value2);
//매도
sellcond= value4 < -100 && stime > 92000 && stime < 144000;
//매도청산
exitshortcond= crossup(value1, value2);
if date != date[1] then{
cnt = 0;
}
##손절
##트레일링스탑
if marketposition()==1 then
setstoptrailing(0.3, 0.6, pointstop);
else if marketposition() == -1 then
SetStopTrailing(0.4, 0.8, pointstop) ;
else
SetStopTrailing(0,0);
if marketposition() == 0 and buycond and cnt < 2 then
Buy();
if marketposition() == 1 and exitlongcond then
Exitlong();
if marketposition() == 0 and sellcond and cnt < 2 then
Sell();
if marketposition() == -1 and exitshortcond then
Exitshort();
if C < entryprice()-0.2 and marketposition() == 1 then{
exitlong("매수손절");
cnt = cnt +1;
}
if C > entryprice()+0.3 and marketposition() == -1 then{
exitshort("매도손절");
cnt = cnt +1;
}
[손절매 2번연속 발생시 다음진입 2배수량]
Input : P1(5), p2(20), p3(60); //이평변수
input : p4(17); //cci
var : value1(0), value2(0), value3(0), value4(0),cnt(0),buyval(0),sellval(0);
Var : buycond(0), exitlongcond(0), sellcond(0),exitshortcond(0); //매매상황
value1 = ma(C,p1);
value2 = ma(C,p2);
value3 = ma(C,p3);
value4 = cci(p4);
//매수
Buycond = value4 > 100 && stime > 92000 && stime < 144000;
//매수청산
exitlongcond= Crossdown(value1,value2);
//매도
sellcond= value4 < -100 && stime > 92000 && stime < 144000;
//매도청산
exitshortcond= crossup(value1, value2);
if marketposition() == 0 and buycond and cnt < 2 then{
Buy("매수1",onclose,def,1);
var1 = 0;
}
if marketposition() == 0 and sellcond and cnt < 2 then{
Sell("매도1",onclose,def,1);
var2 = 0;
}
if marketposition() == 0 and buycond and cnt == 2 then{
Buy("매수2",onclose,def,2);
var1 = 0;
cnt = 0;
}
if marketposition() == 0 and sellcond and cnt == 2 then{
Sell("매도2",onclose,def,2);
var2 = 0;
cnt = 0;
}
if marketposition() == 1 and exitlongcond then{
Exitlong("매수청산");
}
if marketposition() == -1 and exitshortcond then{
Exitshort("매도청산");
}
if C < entryprice()-0.2 and marketposition() == 1 then{
exitlong("매수손절");
}
if C > entryprice()+0.3 and marketposition() == -1 then{
exitshort("매도손절");
}
### 최대수익 대비 하락 (0.6 수익후 0.3 손실시)
if marketposition() == 1 and C > entryprice(0)+0.6 then {
var1 = 1;
buyVal = C;
}
if var1 == 1 and C < buyVal-0.4 then{
exitlong("T매수");
}
## 최대수익 대비 하락 (10% 수익후 5% 손실시)
if marketposition() == -1 and C < entryprice(0)-0.8 then {
var2 = -1;
sellVal = C;
}
if var2 == -1 and C > sellVal+0.4 then {
exitshort("T매도");
}
if barssinceexit(1) == 1 then{
if isexitname("매수손절",1) or isexitname("매도손절",1) then{
cnt = cnt+1;
}
if isexitname("T매수",1) or isexitname("T매도",1) or
isexitname("매수청산",1) or isexitname("매도청산",1) then{
cnt = 0;
}
}
즐거운 하루되세요
> 공부중 님이 쓴 글입니다.
> 제목 : 수식 문의
> 아래식은 분챠트를 기준으로 cci가 100 이상이면 매수하고 -100 이하면 매도하여 이평이 크로스되면 각각 청산하는 식으로 만들어 보았습니다
또 각각의 청산시 손절과 최대수익대비하락을 정하여 보았습니다
1. 아래식이 정확하게 작성되었는지 검토를 부탁드리며(아래와 같이 iff(c<entryprice()-0.3 , 1, 0) 과 setstoploss(0.3, pointstop)은 동일한 것인지 알고 싶습니다)
2. 아래의 수식에 기존의 수식틀은 유지하면서 '추가'로
"손절매가 2번 발생시 그날의 매매는 하지 않는다"와
"2번 연속으로 손절매가 발생할시 다음번 진입신호때에는 평소의 1계약이 아닌 2계약으로 진입한다"는 조건을 더하려면 어떻게 해야 하는지 도와 주십시오(연속 매수/도 신호인 경우와 그렇지 않을 경우를 구분하여 부탁드립니다.)
감사합니다
Input : P1(5), p2(20), p3(60);//이평변수
input: p4(17);//cci
var:value1(0), value2(0), value3(0), value4(0);
Var: buycond(0), exitlongcond(0), sellcond(0),exitshortcond(0);//매매상황
value1 = ma(C,p1);
value2 = ma(C,p2);
value3 = ma(C,p3);
value4 = cci(p4);
Buycond = //매수
iff(value4>100, 1, 0) &&
iff (time>092000 && time<144000, 1, 0);
exitlongcond=//매수청산
iff((Crossdown (value1, value2)), 1, 0);
if marketposition()==1 then{
iff (c<entryprice()-0.2, 1, 0);
setstoptrailing(0.3, 0.6, pointstop);
}
sellcond=//매도
iff(value4<-100, 1, 0)&&
iff (time>092000 && time<144000, 1, 0);
exitshortcond=//매도청산
iff((crossup (value1, value2)),1, 0);
if marketposition()==-1 then{
setstoploss(0.3, pointstop);
SetStopTrailing(0.4, 0.8, pointstop) ;
}
if buycond then
Buy();
if exitlongcond then
Exitlong();
if sellcond then
Sell();
if exitshortcond then
Exitshort();