예스스탁
예스스탁 답변
2022-07-12 10:06:57
안녕하세요
예스스탁입니다.
1
올리신 내용과 같이 평단가는 각진입별수량*가격을 합산하고 총수량으로 나누어 계산합니다.
C매수가 된 시점까지는 평단가는 9040입니다.
하지만 7월11일 11시23분에 3% 청산이 발생하면
총 65주 중 26주가 매도가 되고 차트상 A매수부터 수량이 차감되어 나가게 됩니다.
B매수 17, C매수 22개가 남게 되어 평단가가 8932로 변경이 발생합니다.
그러므로 11시24분봉의 시가가 9320으로
평단가+3%,평단가+4%보다 높기에 3%와 4%가 발생한것입니다.
평단가를 진입시점의 값으로 고정해서 사용하고자 하시면
진입발생시마다 변수에 값을 저장해 사용하시면 됩니다.
2
if Condition1 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수"))Then
ExitLong("3%익절",AtLimit,AvgEntryPrice*1.03,"",Floor(Var3*0.4),1);
3%익절은 최근 진입이 A매수,B매수,C매수이고 가격이 평단가 3%이상이기만 하면 발생하게 됩니다.
첨부하신 리포트를 보시면 7월11일 11시 23분에 3% 조건이 만족해서 9320에 청산이 되고
다음봉시가가 3%조건을 다시 충족하므로 또 발생하게 됩니다.
AtLimit은 가격이 상승해서 터치하는 것을 의미하지 않습니다.
단지 해당가격 위이기만 하면 발생하게 됩니다.
그러므로 3%,4%등의 청산이 진입이후 한번만 발생하게 해야 하는데
작성하신 식에서는 이런 내용이 없습니다.
수식에서 condition1~condition5가 있는데 진입청산시 모두 false만 저장되게 되어 있어
어떠 용도도 없는 변수입니다.
진입이 발생하면 각 청산이 동작할 수 있게 하고
해당 청산이 발생하면 다음진입이 발생하기 전까지는 추가로 발생하지 않게 수정해 드립니다.
3
동일변수가 여러군데에서 사용되고 있습니다.
if DAYClose(1) >= DayClose(2)*1.29
OR DAYClose(2) >= DayClose(3)*1.29
OR DAYClose(3) >= DayClose(4)*1.29
OR DAYClose(4) >= DayClose(5)*1.29
OR DAYClose(5) >= DayClose(6)*1.29
OR DAYClose(6) >= DayClose(7)*1.29
Then
Condition1 = TRUE; #1번<-------------------
위와 같이 최근 6일 동안 29%이상 상승한 날이 하루이상 있으면
Condition1이 true나 false이기도 하고
아래와 같이 진입이나 청산이 발생할때 false가 저장되기도 합니다.
#매수진입
if MarketPosition == 1 Then
{
#전봉대비 수량 감소(일부 청산발생을 위미)
if CurrentContracts < CurrentContracts[1] Then
{
#청산가 저장
var1 = LatestExitPrice(0);
Condition1 = False;#2번<-------------------
....
}
#전봉대비 수량 증가(추가 진입발생을 의미)
if CurrentContracts > CurrentContracts[1] Then
{
#현재수량 저장
Var3 = CurrentContracts;
Condition1 = False;#2번<-------------------
.....
}
}
진입에 6일중 29% 상숭여부는 다른이름으로 변경해 드립니다.
4
input : 고점(7000);
input : 원금(1000000);
var : A1(0),A2(0),A3(0),A4(0),A5(0), 손절(0);
Var : day(0),EntryDay(0),entry(False),dd(0),ED(0);
A1 = 고점*0.95;
A2 = 고점*0.93;
A3 = 고점*0.91;
A4 = 고점*0.89;
A5 = 고점*0.87;
손절 = 고점*0.85;
if Bdate != Bdate[1] Then
{
Condition1 = False;
entry = true;
day = day+1;
dd = dd+1;
}
if TotalTrades > TotalTrades[1] Then
entry = False;
if DAYClose(1) >= DayClose(2)*1.29
OR DAYClose(2) >= DayClose(3)*1.29
OR DAYClose(3) >= DayClose(4)*1.29
OR DAYClose(4) >= DayClose(5)*1.29
OR DAYClose(5) >= DayClose(6)*1.29
OR DAYClose(6) >= DayClose(7)*1.29
Then
Condition11 = TRUE;
if condition11 == true AND MarketPosition == 0 and entry == true and c > J1 Then
Buy("A매수",AtLimit,J1,Floor((원금*0.2)/A1));
if condition11 == true and entry == true and LatestExitName(1) != "손절" AND ((LatestEntryName(0) == "A매수") OR (MarketPosition == 0 AND C < J1 AND C >= J2)) Then
Buy("B매수",AtLimit,J2,Floor((원금*0.2)/A2));
if condition11 == true and entry == true and LatestExitName(1) != "손절" AND ((LatestEntryName(0) == "B매수") OR (MarketPosition == 0 AND C < J2 AND C >= J3)) Then
Buy("C매수",AtLimit,J3,Floor((원금*0.2)/A3));
if condition11 == true and entry == true and LatestExitName(1) != "손절" AND ((LatestEntryName(0) == "C매수") OR (MarketPosition == 0 AND C < J3 AND C >= J4)) Then
Buy("D매수",AtLimit,J4,Floor((원금*0.2)/A4));
if condition11 == true and entry == true and LatestExitName(1) != "손절" AND ((LatestEntryName(0) == "D매수") OR (MarketPosition == 0 AND C < J4 AND C >= J5)) Then
Buy("E매수",AtLimit,J5,Floor((원금*0.2)/A5));
#매수진입
if MarketPosition == 1 Then
{
#전봉대비 수량 감소(일부 청산발생을 위미)
if CurrentContracts < CurrentContracts[1] Then
{
#청산가 저장
var1 = LatestExitPrice(0);
if LatestExitName(0) == "3%익절" or LatestExitName(0) == "1-D%익절" or LatestExitName(0) == "본절" Then
Condition1 = true;
if LatestExitName(0) == "4%익절" or LatestExitName(0) == "2-D%익절" or LatestExitName(0) == "1-E%익절" Then
Condition2 = true;
if LatestExitName(0) == "5%익절" or LatestExitName(0) == "3-D%익절" or LatestExitName(0) == "2-E%익절" Then
Condition3 = true;
if LatestExitName(0) == "7%익절" or LatestExitName(0) == "4-D%익절" Then
Condition4 = true;
}
#전봉대비 수량 증가(추가 진입발생을 의미)
if CurrentContracts > CurrentContracts[1] Then
{
#현재수량 저장
Var3 = CurrentContracts;
Var4 = AvgEntryPrice;
Condition1 = False;
Condition2 = False;
Condition3 = False;
Condition4 = False;
}
if var1 > 0 and C < AvgEntryPrice then
ExitLong("bx");
if Condition1 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수"))Then
ExitLong("3%익절",AtLimit,Var4*1.03,"",Floor(Var3*0.4),1);
if Condition2 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수")) Then
ExitLong("4%익절",AtLimit,Var4*1.04,"",Floor(Var3*0.3),1);
if Condition3 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수")) Then
ExitLong("5%익절",AtLimit,Var4*1.05,"",Floor(Var3*0.1),1);
if Condition4 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수")) Then
ExitLong("7%익절",AtLimit,Var4*1.07,"",Floor(Var3*0.1),1);
ExitLong("10%익절",AtLimit,Var4*1.10);
if Condition1 == False AND ((LatestEntryName(0) == "D매수"))Then
ExitLong("1-D%익절",AtLimit,Var4*1.01,"",Floor(Var3*0.3),1);
if Condition2 == False AND ((LatestEntryName(0) == "D매수")) Then
ExitLong("2-D%익절",AtLimit,Var4*1.02,"",Floor(Var3*0.3),1);
if Condition3 == False AND ((LatestEntryName(0) == "D매수")) Then
ExitLong("3-D%익절",AtLimit,Var4*1.03,"",Floor(Var3*0.3),1);
if Condition4 == False AND ((LatestEntryName(0) == "D매수")) Then
ExitLong("4-D%익절",AtLimit,Var4*1.04,"",Floor(Var3*0.1),1);
if Condition1 == False AND ((LatestEntryName(0) == "E매수"))Then
ExitLong("본절",AtLimit,Var4*1.003,"",Floor(Var3*0.5),1);
if Condition2 == False AND ((LatestEntryName(0) == "E매수")) Then
ExitLong("1-E%익절",AtLimit,Var4*1.01,"",Floor(Var3*0.4),1);
if Condition3 == False AND ((LatestEntryName(0) == "E매수")) Then
ExitLong("2-E%익절",AtLimit,Var4*1.02,"",Floor(Var3*0.1),1);
}
Else#매수진입중이 아니면
{
#변수 0으로 초기화
var1 = 0;
Var2 = 0;
}
if MarketPosition == 1 Then
ExitLong("손절",AtStoP,손절);
즐거운 하루되세요
> 맴맴잉 님이 쓴 글입니다.
> 제목 : 시스템식 문의 드립니다.
> 예전에 시스템식을 작성요청드려서 작성되었던 시스템식입니다.
그런데 일부 이상한 부분이 있어 혼자선 수정이 불가하여 요청드립니다.
문제점 1. 3%,4%,5%,7%,10% 차례대로 분할매도청산 식에서
평단가가 3%가 되었을때 매도를 안하다가 4% 가 되면 4%로 매도되고
주가가 떨어지면서 3%가 매도가 됩니다.
결과론적으로 condition2 가 매도가 되어야 condition1 이 시스템식이
적용됩니다.
문제점 2. 위의 그림파일을 보시다시피 3%,4%,5%,7%,10% 차례대로 분할매도청산 되는
부분에서 성능보고서와 같이 매도가 되었는데, 실제 차트로는 10%까지 분할
매도 되어야 하는데 왜 안되는건지 이상합니다.
위 그림파일중에 엑셀파일을 보시면 아시겠지만 65주 중에서 해당비중으로
매도가 되어야 하는데 왜 성능보고서 처럼 적용되는지
확인 부탁드리겠습니다. ㅜ.ㅜ
참고로 타점이 A1 타점만 적용되었다면 제대로 적용되는데, 분할매수되면
꼬이는것 같습니다.
------------------------------------------------------------------
input : 고점(7000);
input : 원금(1000000);
var : A1(0),A2(0),A3(0),A4(0),A5(0), 손절(0);
Var : day(0),EntryDay(0),entry(False),dd(0),ED(0);
A1 = 고점*0.95;
A2 = 고점*0.93;
A3 = 고점*0.91;
A4 = 고점*0.89;
A5 = 고점*0.87;
손절 = 고점*0.85;
if Bdate != Bdate[1] Then
{
Condition1 = False;
entry = true;
day = day+1;
dd = dd+1;
}
if TotalTrades > TotalTrades[1] Then
entry = False;
if DAYClose(1) >= DayClose(2)*1.29
OR DAYClose(2) >= DayClose(3)*1.29
OR DAYClose(3) >= DayClose(4)*1.29
OR DAYClose(4) >= DayClose(5)*1.29
OR DAYClose(5) >= DayClose(6)*1.29
OR DAYClose(6) >= DayClose(7)*1.29
Then
Condition1 = TRUE;
if condition1 == true AND MarketPosition == 0 and entry == true and c > J1 Then
Buy("A매수",AtLimit,J1,Floor((원금*0.2)/A1));
if condition1 == true and entry == true and LatestExitName(1) != "손절" AND ((LatestEntryName(0) == "A매수") OR (MarketPosition == 0 AND C < J1 AND C >= J2)) Then
Buy("B매수",AtLimit,J2,Floor((원금*0.2)/A2));
if condition1 == true and entry == true and LatestExitName(1) != "손절" AND ((LatestEntryName(0) == "B매수") OR (MarketPosition == 0 AND C < J2 AND C >= J3)) Then
Buy("C매수",AtLimit,J3,Floor((원금*0.2)/A3));
if condition1 == true and entry == true and LatestExitName(1) != "손절" AND ((LatestEntryName(0) == "C매수") OR (MarketPosition == 0 AND C < J3 AND C >= J4)) Then
Buy("D매수",AtLimit,J4,Floor((원금*0.2)/A4));
if condition1 == true and entry == true and LatestExitName(1) != "손절" AND ((LatestEntryName(0) == "D매수") OR (MarketPosition == 0 AND C < J4 AND C >= J5)) Then
Buy("E매수",AtLimit,J5,Floor((원금*0.2)/A5));
#매수진입
if MarketPosition == 1 Then
{
#전봉대비 수량 감소(일부 청산발생을 위미)
if CurrentContracts < CurrentContracts[1] Then
{
#청산가 저장
var1 = LatestExitPrice(0);
Condition1 = False;
Condition2 = False;
Condition3 = False;
Condition4 = False;
Condition5 = False;
}
#전봉대비 수량 증가(추가 진입발생을 의미)
if CurrentContracts > CurrentContracts[1] Then
{
#현재수량 저장
Var3 = CurrentContracts;
Condition1 = False;
Condition2 = False;
Condition3 = False;
Condition4 = False;
Condition5 = False;
}
if var1 > 0 and C < AvgEntryPrice then
ExitLong("bx");
if Condition1 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수"))Then
ExitLong("3%익절",AtLimit,AvgEntryPrice*1.03,"",Floor(Var3*0.4),1);
if Condition2 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수")) Then
ExitLong("4%익절",AtLimit,AvgEntryPrice*1.04,"",Floor(Var3*0.3),1);
if Condition3 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수")) Then
ExitLong("5%익절",AtLimit,AvgEntryPrice*1.05,"",Floor(Var3*0.1),1);
if Condition4 == False AND ((LatestEntryName(0) == "A매수") OR (LatestEntryName(0) == "B매수") or (LatestEntryName(0) == "C매수")) Then
ExitLong("7%익절",AtLimit,AvgEntryPrice*1.07,"",Floor(Var3*0.1),1);
ExitLong("10%익절",AtLimit,AvgEntryPrice*1.10);
if Condition1 == False AND ((LatestEntryName(0) == "D매수"))Then
ExitLong("1-D%익절",AtLimit,AvgEntryPrice*1.01,"",Floor(Var3*0.3),1);
if Condition2 == False AND ((LatestEntryName(0) == "D매수")) Then
ExitLong("2-D%익절",AtLimit,AvgEntryPrice*1.02,"",Floor(Var3*0.3),1);
if Condition3 == False AND ((LatestEntryName(0) == "D매수")) Then
ExitLong("3-D%익절",AtLimit,AvgEntryPrice*1.03,"",Floor(Var3*0.3),1);
if Condition4 == False AND ((LatestEntryName(0) == "D매수")) Then
ExitLong("4-D%익절",AtLimit,AvgEntryPrice*1.04,"",Floor(Var3*0.1),1);
if Condition1 == False AND ((LatestEntryName(0) == "E매수"))Then
ExitLong("본절",AtLimit,AvgEntryPrice*1.003,"",Floor(Var3*0.5),1);
if Condition2 == False AND ((LatestEntryName(0) == "E매수")) Then
ExitLong("1-E%익절",AtLimit,AvgEntryPrice*1.01,"",Floor(Var3*0.4),1);
if Condition3 == False AND ((LatestEntryName(0) == "E매수")) Then
ExitLong("2-E%익절",AtLimit,AvgEntryPrice*1.02,"",Floor(Var3*0.1),1);
}
Else#매수진입중이 아니면
{
#변수 0으로 초기화
var1 = 0;
Var2 = 0;
}
if MarketPosition == 1 Then
ExitLong("손절",AtStoP,손절);