답변완료
시스템식 요청드립니다.
안녕하세요 수식을 작성하는데 어려움이 있어 이렇게 글을 남깁니다.
위의 그림 2, 3번을 보시면 대략적으로 그림으로 작성하였습니다.
타점 에서 100주 매수후 30주 매도 하고 중간에 30주 매도 해서 총 40주가 남은
상태에서 타점 1로 60주 매수해서 다시 100주가 되도록 맞췄습니다.
그런데 타점1 5% 익절에서 30주만 매도가 되어야 하는데
그림 1 성능보고서를 보시면, 타점에서 30주매도, 타점 1에서 30주 매도 총 60주가
매도 되었습니다.
타점, 타점 1이 따로따로 시스템식이 적용 되는것 같은데
어떻게 해야 할지 부탁드리겠습니다.
input : 베팅금(1000000);
input : 시작날짜 (20240113),Xtime(110000) ;
input : 타점(5000),손절(1000);
var : P618(0),P5(0),P382(0),HH(0),LL(0);
Var : day(0),EntryDay(0),entry(False),dd(0),ED(0);
if sDate >= 시작날짜 Then
{
if Bdate != Bdate[1] Then
{
entry = true;
day = day+1;
dd = dd+1;
}
if HH == 0 or (HH > 0 and H > HH) Then
HH = H;
#고점갱신용 수식
if LL == 0 or (LL > 0 and L < LL) Then
LL = L;
#저점갱신용 수식
}
P618 = LL+(HH-LL)*0.618;
P5 = LL+(HH-LL)*0.5;
P382 = LL+(HH-LL)*0.382;
if MarketPosition == 0 and entry == true and c > 타점 Then
Buy("타점",AtLimit,타점,Floor((베팅금)/타점));
if MarketPosition == 1 Then
{
Condition1 = False;
If C >= HH[1] AND LatestExitName(0) == "타점 5%익절 P5청산" Then
{
Condition1 = true;
Buy("타점1",OnClosE,DeF,Floor((베팅금)/타점*0.6));
}
If C >= HH[1] AND LatestExitName(0) == "타점 10%익절 P618청산" Then
{
Condition1 = true;
Buy("타점2",OnClosE,DeF,Floor((베팅금)/타점*0.8));
}
#전봉대비 수량 감소(일부 청산발생을 위미)
if CurrentContracts < CurrentContracts[1] Then
{
#청산가 저장
var1 = LatestExitPrice(0);
if LatestExitName(0) == "타점 5%익절" or LatestExitName(0) == "타점1 5%익절" or LatestExitName(0) == "타점2 5%익절" Then
Condition11 = true;
if LatestExitName(0) == "타점 5%익절 P5청산" or LatestExitName(0) == "타점 10%익절" or LatestExitName(0) == "타점1 5%익절 P618청산"
or LatestExitName(0) == "타점1 10%익절" or LatestExitName(0) == "타점2 5%익절 P618청산" or LatestExitName(0) == "타점2 10%익절" Then
Condition22 = true;
if LatestExitName(0) == "타점 5%익절 P382청산" or LatestExitName(0) == "타점 10%익절 P618청산" or LatestExitName(0) == "타점1 5%익절 P5청산"
or LatestExitName(0) == "타점1 10%익절 P618청산" or LatestExitName(0) == "타점2 5%익절 P5청산" or LatestExitName(0) == "타점2 10%익절 P618청산" Then
Condition33 = true;
if LatestExitName(0) == "타점 10%익절 P5청산" or LatestExitName(0) == "타점1 10%익절 P5청산" or LatestExitName(0) == "타점2 10%익절 P5청산" Then
Condition44 = true;
}
#전봉대비 수량 증가(추가 진입발생을 의미)
if CurrentContracts > CurrentContracts[1] Then
{
#현재수량 저장
Var3 = CurrentContracts;
Var4 = AvgEntryPrice;
Condition11 = False;
Condition22 = False;
Condition33= False;
Condition44 = False;
}
if (LatestEntryName(0) == "타점") and Condition1 == False Then
ExitLong("타점 5%익절",AtLimit,AvgEntryPrice*1.05,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점 5%익절") and c <= P5 Then
ExitLong("타점 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점 5%익절 P5청산") and c <= P382 Then
ExitLong("타점 5%익절 P382청산",AtLimit,P382,"",Floor(베팅금/타점)*0.4);
if (LatestEntryName(0) == "타점") and Condition1 == False Then
ExitLong("타점 10%익절",AtLimit,AvgEntryPrice*1.2,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점 10%익절") and c <= P618 Then
ExitLong("타점 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2);
if (LatestExitName(0) == "타점 10%익절 P618청산") and c <= P5 Then
ExitLong("타점 10%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.2);
if (LatestEntryName(0) == "타점1")Then
ExitLong("타점1 5%익절",AtLimit,latestEntryPrice*1.05,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점1 5%익절") and c <= P618 Then
ExitLong("타점1 5%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점1 5%익절 P618청산") and c <= 5 Then
ExitLong("타점1 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.4);
if (LatestEntryName(0) == "타점1") Then
ExitLong("타점1 10%익절",AtLimit,latestEntryPrice*1.1,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점1 10%익절") and c <= P618 Then
ExitLong("타점1 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2);
if (LatestExitName(0) == "타점1 10%익절 P618청산") and c <= P5 Then
ExitLong("타점1 10%익절 P5청산",AtLimit,P5,"",(베팅금/타점)*0.2);
if (LatestEntryName(0) == "타점2")Then
ExitLong("타점2 5%익절",AtLimit,latestEntryPrice*1.05,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점2 5%익절") and c <= P618 Then
ExitLong("타점2 5%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점2 5%익절 P618청산") and c <= 5 Then
ExitLong("타점2 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.4);
if (LatestEntryName(0) == "타점2") Then
ExitLong("타점2 10%익절",AtLimit,latestEntryPrice*1.1,"",(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점2 10%익절") and c <= P618 Then
ExitLong("타점2 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2);
if (LatestExitName(0) == "타점2 10%익절 P618청산") and c <= P5 Then
ExitLong("타점2 10%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.2);
}
if MarketPosition == 1 and sTime > xtime and 손절 >= c Then
ExitLong("손절");
if MarketPosition == 1 and (LatestEntryName(0) == "타점1") and c <= latestEntryPrice*0.96 Then
ExitLong("5%돌파손절");
if MarketPosition == 1 and (LatestEntryName(0) == "타점2") and c <= latestEntryPrice*0.96 Then
ExitLong("10%돌파손절");
2024-03-10
804
글번호 177327
시스템