답변완료
함수요청
안녕하세요?
계좌는 한개인데 시스템 A와 시스템 B를 동시에 돌리고 싶습니다.
전략 실행 차트를 각각 띄우고 각각 적용하는 거 말고
시스템 A와 시스템 B를 한개의 스트립트로 재작성해서
시스템 C를 만들고 싶습니다.
시스템 A와 시스템 B를 각각 동시에 돌린 것과 시스템 C 한개를 돌린 것과 신호와 손익이 같도록 작성 요청드립니다.
시스템 A = 글번호 77970번에서 작성주신 스크립트
시스템 B = 글번호 77955번에서 작성주신 스크립트입니다.
/시스템 A
var : T(0),S(0),mav(0);
mav = ma(c,20);
if Bdate != Bdate[1] Then
{
T = 0;
S = 0;
if L[1] > mav[1] and H < mav Then
Sell("s",AtMarket);
if H[1] < mav[1] and L > mav Then
Buy("b",AtMarket);
}
if MarketPosition == -1 Then
{
if CrossUp(c,mav) Then
ExitShort("sx",AtMarket);
if L < DayLow(0)[1] and L[1] != DayLow(0)[1] Then
{
var1 = var1+1;
if var1 == 3 Then
ExitShort("sx1");
}
}
Else
var1 = 0;
if MarketPosition == 1 Then
{
if CrossDown(c,mav) Then
ExitLong("bx",AtMarket);
if H > DayHigh(0)[1] and H[1] != DayHigh(0)[1] Then
{
var2 = var2+1;
if var2 == 3 Then
ExitLong("bx1");
}
}
Else
Var2 = 0;
SetStopEndofday(151500);
/시스템B
var : T(0),S(0),mav(0);
mav = ma(c,20);
if Bdate != Bdate[1] Then
{
T = 0;
S = 0;
if L > mav Then
T = -1;
if H < mav Then
T = 1;
}
if T == -1 and CrossDown(C,mav) Then
{
S = S+1;
if S == 2 Then
Sell();
}
if T == 1 and CrossUp(C,mav) Then
{
S = S+1;
if S == 2 Then
Buy();
}
if MarketPosition == 1 and Bdate == Bdate[1] and C < DayLow(0)[1] Then
ExitLong("bx",AtMarket);
if MarketPosition == -1 and Bdate == Bdate[1] and C > DayHigh(0)[1] Then
ExitShort("sx",AtMarket);
SetStopEndofday(151500);
2022-07-12
1413
글번호 160678
시스템
답변완료
수식 수정 부탁드립니다.
안녕하십니까
수식 수정 부탁드립니다.
--------------------------------------------------------------
input : P(20);
var : cnt(0),sum1(0),mav1(0),sum2(0),mav2(0),t(0),count(0);
var : 상한가(0), UpLimit(0);
var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0);
Array : 상[100](False);
if date >= 19981207 then
{
if date < 20050328 && CodeCategory() == 2 then
UpLimit = (BP[0] * 1.12);
Else if date >= 20050328 and date < 20150615 Then
UpLimit = (BP[0] * 1.15);
Else
UpLimit = (BP[0] * 1.30);
if CodeCategory() == 2 then
{
if date >= 20030721 then
{
up1 = int(UpLimit/100+0.00001)*100;
up2 = int(UpLimit/100+0.00001)*100;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
else
{
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/10+0.00001)*10;
up7 = int(UpLimit/1+0.00001)*1;
}
}
Else
{
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
if CodeCategory() == 1 || CodeCategory() == 2 then
{
if sdate < 20101004 Then
{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up6);
}
Else
{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up7);
}
}
else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF
상한가 = up6;
}
}
if Bdate != Bdate[1] Then
{
For cnt = 99 DownTo 1
{
상[cnt] = 상[cnt-1];
}
}
if C == 상한가 Then
상[0] = true;
Else
상[0] = False;
sum1 = 0;
sum2 = NextBarOpen;
count = 0;
For cnt = 0 to P-1
{
sum1 = sum1 + DayClose(cnt);
if cnt < P-1 Then
sum2 = sum2 + DayClose(cnt);
if 상[cnt] == true Then
count = count+1;
}
mav1 = sum1/P;
mav2 = sum2/P;
if NextBarSdate != sDate Then
{
T = 0;
if C <= mav1*1.05 and C >= mav1*0.95 and count >= 1 Then
{
T = 1;
if NextBarOpen < mav2 Then
{
T = 2;
Buy("b11",AtMarket);
}
Else
{
T = 3;
Buy("b12",AtLimit,mav2);
}
}
Condition1 = False;
}
Else
{
if L <= mav1 Then
Condition1 = true;
if Condition1 == False and T == 3 Then
Buy("b2",AtLimit,mav2);
}
SetStopEndofday(151800);
SetStopLoss(5,PercentStop);
현재 조건
#ㅇ 매수
# 1. 최근 20거래일 중 종가 상한가
# 2. 일봉 상 가격 형성이 20일선 기준 +-5% 이내
# 3. 당일 시가가 일봉기준 20일선 위에서 시작하면 20일 평균가격으로 매수 주문
# (가격을 지정하여 매수 주문이 불가능 하면, 당일 일봉 상 20일 평균가격에 닿거나 하향하면 바로 매수)
# 4. 당일 시가가 일봉기준 20일선 아래에 위치하면 시가로 매수 주문
#매수 주문은 시가가 전일종가 대비 +-20 이내에서 형성될때만 나갈수있게 부탁드립니다.
#ㅇ 매도
#오후 3시 18분 전량매도
수정요청
위 조건 중 기준선 을 5일, 10일 선으로 각각 수정부탁드립니다.
잘 부탁드립니다.
감사합니다.
2022-07-12
1469
글번호 160668
시스템
답변완료
시스템식 문의 드립니다.
예전에 시스템식을 작성요청드려서 작성되었던 시스템식입니다.
그런데 일부 이상한 부분이 있어 혼자선 수정이 불가하여 요청드립니다.
문제점 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,손절);
2022-07-11
1914
글번호 160662
시스템