커뮤니티
이 식에서 매매횟수를 1회로 제한이 되도록 부탁드립니다.
2004-01-14 21:49:56
1951
글번호 1986
먼저 감사드리며,
제목처럼 이 식에서 당일 매수후 청산, 매도후 청산 으로 한번 매매후에는 매매가
일어나지 못하도록 하는 수식을 부탁드립니다...
var : Cond1(0), Cond2(0), Cond3(0), Cond4(0), Cond5(0), Cond6(0),
Cond11(0), Cond22(0), Cond33(0), Cond44(0), Cond55(0), Cond66(0),
buyCond(0), sellCond(0), bPosition(0), sposition(0);
if date != date[1] then {
bposition = 0;
sposition = 0;
}
Cond1 = crossup(C, dayopen(0)+0.3); //매수조건1
Cond2 = crossup(C, dayopen(0)+0.6); //매수조건2
Cond3 = crossup(C, dayopen(0)+0.9); //매수조건3
Cond4 = crossdown(C, dayopen(0)-0.3); //매수청산조건1
Cond5 = crossdown(C, dayopen(0)+0.3); //매수청산조건2
Cond6 = crossdown(C, dayopen(0)+0.6); //매수청산조건3
Cond11 = crossdown(C, dayopen(0)-0.3); //매도조건1
Cond22 = crossdown(C, dayopen(0)-0.6); //매도조건2
Cond33 = crossdown(C, dayopen(0)-0.9); //매수조건3
Cond44 = crossup(C, dayopen(0)+0.3); //매도청산조건1
Cond55 = crossup(C, dayopen(0)-0.3); //매도청산조건2
Cond66 = crossup(C, dayopen(0)-0.6); //매도청산조건3
//매수식
if bposition != 1 then Begin
if Cond1 then {
buy();
buyCond = 1;
bposition = 1;
}
if Cond2 then {
buy();
buyCond = 2;
bposition = 1;
}
if Cond3 then {
buy();
buyCond = 3;
bposition = 1;
}
End;
//매수청산식
if buyCond == 1 and Cond4 then {
exitlong();
bPosition = 0;
}
if buyCond == 2 and Cond5 then {
exitlong();
bPosition = 0;
}
if buyCond == 3 and Cond6 then {
exitlong();
bPosition = 0;
}
//매도식
if sposition != 1 then Begin
if Cond11 then {
sell();
sellCond = 1;
sposition = 1;
}
if Cond22 then {
sell();
sellCond = 2;
sposition = 1;
}
if Cond33 then {
sell();
sellCond = 3;
sposition = 1;
}
End;
//매도청산식
if sellCond == 1 and Cond44 then {
exitlong();
sPosition = 0;
}
if sellCond == 2 and Cond55 then {
exitlong();
sPosition = 0;
}
if sellCond == 3 and Cond66 then {
exitlong();
sPosition = 0;
}
감사합니다.
답변 1
예스스탁 예스스탁 답변
2004-01-15 10:30:55
안녕하세요? 예스스탁입니다...
문의하신 식을 작성하면 다음과 같습니다....
input : Number(1);
var : Cond1(0), Cond2(0), Cond3(0), Cond4(0), Cond5(0), Cond6(0),
Cond11(0), Cond22(0), Cond33(0), Cond44(0), Cond55(0), Cond66(0),
buyCond(0), sellCond(0), bPosition(0), sposition(0), cnt(0);
if date != date[1] then {
bposition = 0;
sposition = 0;
cnt = 0;
}
Cond1 = crossup(C, dayopen(0)+0.3); //매수조건1
Cond2 = crossup(C, dayopen(0)+0.6); //매수조건2
Cond3 = crossup(C, dayopen(0)+0.9); //매수조건3
Cond4 = crossdown(C, dayopen(0)-0.3); //매수청산조건1
Cond5 = crossdown(C, dayopen(0)+0.3); //매수청산조건2
Cond6 = crossdown(C, dayopen(0)+0.6); //매수청산조건3
Cond11 = crossdown(C, dayopen(0)-0.3); //매도조건1
Cond22 = crossdown(C, dayopen(0)-0.6); //매도조건2
Cond33 = crossdown(C, dayopen(0)-0.9); //매수조건3
Cond44 = crossup(C, dayopen(0)+0.3); //매도청산조건1
Cond55 = crossup(C, dayopen(0)-0.3); //매도청산조건2
Cond66 = crossup(C, dayopen(0)-0.6); //매도청산조건3
//매수식
if bposition != 1 then Begin
if Cond1 and cnt < Number then {
buy();
cnt = cnt +1;
buyCond = 1;
bposition = 1;
}
if Cond2 and cnt < Number then {
buy();
cnt = cnt +1;
buyCond = 2;
bposition = 1;
}
if Cond3 and cnt < Number then {
buy();
cnt = cnt +1;
buyCond = 3;
bposition = 1;
}
End;
//매수청산식
if buyCond == 1 and Cond4 then {
exitlong();
bPosition = 0;
}
if buyCond == 2 and Cond5 then {
exitlong();
bPosition = 0;
}
if buyCond == 3 and Cond6 then {
exitlong();
bPosition = 0;
}
//매도식
if sposition != 1 then Begin
if Cond11 and cnt < Number then {
sell();
cnt = cnt +1;
sellCond = 1;
sposition = 1;
}
if Cond22 and cnt < Number then {
sell();
cnt = cnt +1;
sellCond = 2;
sposition = 1;
}
if Cond33 and cnt < Number then {
sell();
cnt = cnt +1;
sellCond = 3;
sposition = 1;
}
End;
//매도청산식
if sellCond == 1 and Cond44 then {
exitlong();
sPosition = 0;
}
if sellCond == 2 and Cond55 then {
exitlong();
sPosition = 0;
}
if sellCond == 3 and Cond66 then {
exitlong();
sPosition = 0;
}
즐거운 하루 되세요....
> fjulia 님이 쓴 글입니다.
> 제목 : 이 식에서 매매횟수를 1회로 제한이 되도록 부탁드립니다.
> 먼저 감사드리며,
제목처럼 이 식에서 당일 매수후 청산, 매도후 청산 으로 한번 매매후에는 매매가
일어나지 못하도록 하는 수식을 부탁드립니다...
var : Cond1(0), Cond2(0), Cond3(0), Cond4(0), Cond5(0), Cond6(0),
Cond11(0), Cond22(0), Cond33(0), Cond44(0), Cond55(0), Cond66(0),
buyCond(0), sellCond(0), bPosition(0), sposition(0);
if date != date[1] then {
bposition = 0;
sposition = 0;
}
Cond1 = crossup(C, dayopen(0)+0.3); //매수조건1
Cond2 = crossup(C, dayopen(0)+0.6); //매수조건2
Cond3 = crossup(C, dayopen(0)+0.9); //매수조건3
Cond4 = crossdown(C, dayopen(0)-0.3); //매수청산조건1
Cond5 = crossdown(C, dayopen(0)+0.3); //매수청산조건2
Cond6 = crossdown(C, dayopen(0)+0.6); //매수청산조건3
Cond11 = crossdown(C, dayopen(0)-0.3); //매도조건1
Cond22 = crossdown(C, dayopen(0)-0.6); //매도조건2
Cond33 = crossdown(C, dayopen(0)-0.9); //매수조건3
Cond44 = crossup(C, dayopen(0)+0.3); //매도청산조건1
Cond55 = crossup(C, dayopen(0)-0.3); //매도청산조건2
Cond66 = crossup(C, dayopen(0)-0.6); //매도청산조건3
//매수식
if bposition != 1 then Begin
if Cond1 then {
buy();
buyCond = 1;
bposition = 1;
}
if Cond2 then {
buy();
buyCond = 2;
bposition = 1;
}
if Cond3 then {
buy();
buyCond = 3;
bposition = 1;
}
End;
//매수청산식
if buyCond == 1 and Cond4 then {
exitlong();
bPosition = 0;
}
if buyCond == 2 and Cond5 then {
exitlong();
bPosition = 0;
}
if buyCond == 3 and Cond6 then {
exitlong();
bPosition = 0;
}
//매도식
if sposition != 1 then Begin
if Cond11 then {
sell();
sellCond = 1;
sposition = 1;
}
if Cond22 then {
sell();
sellCond = 2;
sposition = 1;
}
if Cond33 then {
sell();
sellCond = 3;
sposition = 1;
}
End;
//매도청산식
if sellCond == 1 and Cond44 then {
exitlong();
sPosition = 0;
}
if sellCond == 2 and Cond55 then {
exitlong();
sPosition = 0;
}
if sellCond == 3 and Cond66 then {
exitlong();
sPosition = 0;
}
감사합니다.
다음글
이전글