커뮤니티
문의 드립니다..
2005-08-12 10:11:51
1099
글번호 7986
두개의 청산식이 있습니다..
그중 하나는 청산후에 봉 5개 이내에서 조정을 줄때 재진입하려고 합니다..
input:period(10);
# 매수
If marketposition() != 1 then {
if CrossUP(c, ma(c,20)) Then
{ Buy("B"); }
if CrossUP(ma(c,5), ma(c,10)) Then
{ buy("BB");}
}
# 매도
If marketposition() != -1 then {
if Crossdown(c, ma(c,20)) Then
{ sell("S"); }
if Crossdown(ma(c,5), ma(c,10)) Then
{ sell("SS");}
}
#청산
If CrossDown(ma(c,10),ma(c,20)) Then
{ Exitlong("el"); }
If CrossUP(ma(c,10),ma(c,20)) Then
{ Exitshort("es"); }
If marketposition()==1 and crossdown(c,ma(c,5)) then
{ Exitlong("과매수청산"); var1=1 ; }
If marketposition()==-1 and crossup(c,ma(c,5)) then
{ Exitshort("과매도청산"); var1=-1 ; }
#재진입
if marketposition()==0 and exitprice()<5 and var1==1 then
{buy("1",atlimit,ma(c,period)); }
if marketposition()==0 and exitprice()<5 and var1==-1 then
{sell("2",atlimit,ma(c,period)); }
위의 청산식중 과매도청산과 과매수청산에 해당하면 재진입식으로 재진입하려고
하는데요,
의도한대로 신호가 되지 않습니다..
신호가 뒤죽박죽이 됩니다..
과매도청산후에만 재진입매수를, 과매도청산한 후에만 재진입매도를 할 수 있게
부탁드립니다..
감사합니다..
답변 1
예스스탁 예스스탁 답변
2005-08-12 15:25:19
안녕하세요
예스스탁입니다.
올리신 식에서
If marketposition()==1 and crossdown(c,ma(c,5)) then
{ Exitlong("과매수청산"); var1=1 ; }
If marketposition()==-1 and crossup(c,ma(c,5)) then
{ Exitshort("과매도청산"); var1=-1 ; }
#재진입
if marketposition()==0 and exitprice()<5 and var1==1 then
{buy("1",atlimit,ma(c,period)); }
if marketposition()==0 and exitprice()<5 and var1==-1 then
{sell("2",atlimit,ma(c,period)); }
과매수청산과 과매도청산일때 var1에 특정값을 저장하고 그후
재진입이 되면 var1의 값을 초기화 해주지 않았기 때문에
1 혹은 -1값이 계속적으로 유지가 됩니다.
하지만 재진입식이 atlimit주문이므로
if marketposition()==0 and exitprice()<5 and var1==1 then
{buy("1",atlimit,ma(c,period));
var1 = 0 }
과 같이 초기화를 한다고 해도 정확히 그 시점을 못잡을 경우가 생깁니다.
재진입식에 IsExitName() 을 사용하여 제어하시면 됩니다.
If marketposition()==1 and crossdown(c,ma(c,5)) then
{ Exitlong("과매수청산"); }
If marketposition()==-1 and crossup(c,ma(c,5)) then
{ Exitshort("과매도청산"); }
if marketposition()==0 and exitprice()<5 and IsExitName("과매수청산',1) then
{buy("1",atlimit,ma(c,period)); }
if marketposition()==0 and exitprice()<5 and IsExitName("과매도청산',1) then
{sell("2",atlimit,ma(c,period)); }
즐거운 하루되세요
> CJ_vggg1472 님이 쓴 글입니다.
> 제목 : 문의 드립니다..
> 두개의 청산식이 있습니다..
그중 하나는 청산후에 봉 5개 이내에서 조정을 줄때 재진입하려고 합니다..
input:period(10);
# 매수
If marketposition() != 1 then {
if CrossUP(c, ma(c,20)) Then
{ Buy("B"); }
if CrossUP(ma(c,5), ma(c,10)) Then
{ buy("BB");}
}
# 매도
If marketposition() != -1 then {
if Crossdown(c, ma(c,20)) Then
{ sell("S"); }
if Crossdown(ma(c,5), ma(c,10)) Then
{ sell("SS");}
}
#청산
If CrossDown(ma(c,10),ma(c,20)) Then
{ Exitlong("el"); }
If CrossUP(ma(c,10),ma(c,20)) Then
{ Exitshort("es"); }
If marketposition()==1 and crossdown(c,ma(c,5)) then
{ Exitlong("과매수청산"); var1=1 ; }
If marketposition()==-1 and crossup(c,ma(c,5)) then
{ Exitshort("과매도청산"); var1=-1 ; }
#재진입
if marketposition()==0 and exitprice()<5 and var1==1 then
{buy("1",atlimit,ma(c,period)); }
if marketposition()==0 and exitprice()<5 and var1==-1 then
{sell("2",atlimit,ma(c,period)); }
위의 청산식중 과매도청산과 과매수청산에 해당하면 재진입식으로 재진입하려고
하는데요,
의도한대로 신호가 되지 않습니다..
신호가 뒤죽박죽이 됩니다..
과매도청산후에만 재진입매수를, 과매도청산한 후에만 재진입매도를 할 수 있게
부탁드립니다..
감사합니다..