답변완료
수식 수정 부탁드리겠습니다.
국내주식
60분봉 적용 / 종목: kodex200
매수 :
1) 오후 2시 매수
2) 분봉 240 또는 2880 이하일때 매수
3) 총매수금액 2000만원 이하일때 매수
4) 전일 대비 -1~-10 이하일때 분할 매수
매도 :
1)오후 2시 매도
2) 평균매수금액의 10% 수익시 1% 분할매도
3) 평균매수금액의 10% 수익이지만 100주 이하일때 구간별 2~50% 분할매도
문제점
시뮬레이션을 돌려보면 매수는 수식대로 잘 진행되고 있는데...
매도가 시행되지 않는데.. 수식에 문제가 있는것 같아요..
수식 점검 부탁드림니다.~~~
==============================================================================
input : 시작일(20200216);
input : 이평1(240),이평2(2880);
input : 최대투자금액(2000);
var : cond(False),XV(0),vol(0);
var1 = ma(C,이평1);
Var2 = ma(C,이평2);
if Data1(sDate) >= 시작일 Then
{
if
sTime == 140000 and AvgEntryPrice*CurrentContracts < 최대투자금액*10000 Then
{
if c < var1 or c < Var2 Then # 분봉 이하일때 매수 진입
{
if C <= DayClose(1)*0.99 and C > DayClose(1)*0.985 Then
Buy("b1",OnClose,Def,1);
if C <= DayClose(1)*0.985 and C > DayClose(1)*0.980 Then
Buy("b2",OnClose,Def,2);
if C <= DayClose(1)*0.980 and C > DayClose(1)*0.975 Then
Buy("b3",OnClose,Def,3);
if C <= DayClose(1)*0.975 and C > DayClose(1)*0.970 Then
Buy("b4",OnClose,Def,4);
if C <= DayClose(1)*0.970 and C > DayClose(1)*0.965 Then
Buy("b5",OnClose,Def,5);
if C <= DayClose(1)*0.965 and C > DayClose(1)*0.96 Then
Buy("b6",OnClose,Def,6);
if C <= DayClose(1)*0.96 and C > DayClose(1)*0.955 Then
Buy("b7",OnClose,Def,7);
if C <= DayClose(1)*0.955 and C > DayClose(1)*0.95 Then
Buy("b8",OnClose,Def,8);
if C <= DayClose(1)*0.95 Then
Buy("b9",OnClose,Def,9);
}
}
}
if MarketPosition == 1 and sTime == 140000 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
XV = CurrentContracts;
cond = False;
}
if C >= AvgEntryPrice*1.10 Then
cond = true;
if cond == true Then
{
if XV >= 100 Then
vol = Floor(XV*0.01); # 계약수가 100개 이상일때 1% 분할매도
else if XV < 100 and XV >= 50 Then
vol = Floor(XV*0.02); # 계약수가 50개~100 일때 2% 분할매도
else if XV < 50 and XV >= 20 Then
vol = Floor(XV*0.05); # 계약수가 20개~50 일때 5% 분할매도
else if XV < 20 and XV >= 10 Then
vol = Floor(XV*0.10); # 계약수가 10개~20 일때 10% 분할매도
Else
vol = Floor(XV*0.50); # 계약수가 10개이하 일때 50% 분할매도
ExitLong("bx",OnClose,Def,"",vol,2);
}
}
Else
cond = False;
=================================================================================
input : 시작일(20230201);
input : 가격(20000),수량(414); #2900
input : 금액1(10),금액2(13),금액3(16);
input : 최대투자금액(1000);
input : MFI기간1(25),MFI값1(15);
input : MFI기간2(30),MFI값2(20);
input : MFI기간3(35),MFI값3(20);
input : MFI기간4(60),MFI값4(30);
input : MFI기간5(80),MFI값5(35);
input : MFI기간6(100),MFI값6(40);
input : MFI기간7(200),MFI값7(43);
#input : MFI기간7(40),MFI값7(80);
#input : MFI기간8(70),MFI값8(75);
#input : MFI기간9(100),MFI값9(70);
#input : MFI기간10(200),MFI값10(65);
input : 분할매도퍼센트(5);
input : 청산수익률(10);
if Data1(sDate) >= 시작일 Then
{
if MarketPosition == 0 Then
{
if NextBarOpen <= 가격 Then
Buy("bb1",AtStop,가격,수량);
Else
Buy("bb2",AtLimit,가격,수량);
}
if sTime == 140000 and AvgEntryPrice*CurrentContracts < 최대투자금액*10000 and (DayOfWeek(sdate) == 3 or DayOfWeek(sdate) == 3) Then
{
if MFi(MFI기간1) < MFI값1 Then
Buy("b1",OnClose,Def,Floor(금액1*10000/C));
if MFi(MFI기간2) < MFI값2 Then
Buy("b2",OnClose,Def,Floor(금액1*10000/C));
if MFi(MFI기간3) < MFI값3 Then
Buy("b3",OnClose,Def,Floor(금액2*10000/C));
if MFi(MFI기간4) < MFI값4 Then
Buy("b4",OnClose,Def,Floor(금액2*10000/C));
if MFi(MFI기간5) < MFI값5 Then
Buy("b5",OnClose,Def,Floor(금액3*10000/C));
if MFi(MFI기간6) < MFI값6 Then
Buy("b6",OnClose,Def,Floor(금액3*10000/C));
if MFi(MFI기간7) < MFI값7 Then
Buy("b7",OnClose,Def,Floor(금액3*10000/C));
}
if sTime == 140000 and (DayOfWeek(sdate) == 2 or DayOfWeek(sdate) == 4) Then
{
if C > AvgEntryPrice*(1+청산수익률/100) Then # and (( MFi(MFI기간8)>MFI값8) or ( MFi(MFI기간9)>MFI값9) or( MFi(MFI기간10)>MFI값10) or( MFi(MFI기간11)>MFI값11))
ExitLong("bx",OnClose,Def,"",Floor(CurrentContracts*분할매도퍼센트/100),2);
}
}
2023-06-10
566
글번호 169557
시스템