커뮤니티
추가 부탁드리겠습니다.
2015-06-11 16:14:16
125
글번호 87113
아래 수식에 대해서
매수된 수량에 대해서 매수청산이 모두 완료된 경우
MessageLog를 통해 성과를 표시한 후
1시간이 경과된 이후부터 재매수 가능하도록 로직을 보완하고 싶습니다.
ex) 9:05분 1차 매수
9:08분 2차 매수
9:10분 1차 매도
9:20분 전량 매도
MessageLong(분할횟수, 평균단가, 수익금액, 수익률)이 표시됨
10:30분 1차 매수
10:35분 1차 매도
10:40분 전량 매도
MessageLong(분할횟수, 평균단가, 수익금액, 수익률)이 표시됨
위와 같이 9:05분~9:20분까지 매매가 완료된 후 Log를 표시하고
1시간이 경과한 시점부터 재매수를 하여
10:30분~10:40분까지 매매가 완료된 후 Log를 표시함
감사합니다.
input : fdate(20150610), stime_from(090000), stime_to(144500), entry1(1000000),entry2(1000000),entry3(2000000);
input : updn_tm1(15), buy_r1(0.93), buy_r2(0.9), buy_r3(0.87);
var : V1(0),V2(0),V3(0),cnt(0),count(0),updn_p1(0),AVgv(0);
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count+1;
}
if CodeCategoryEx == 11 and BasePrice < 50000 Then {
V1 = int(int(entry1/C)/10)*10;
V2 = int(int(entry2/C)/10)*10;
V3 = int(int(entry3/C)/10)*10;
} Else {
V1 = int(entry1/C);
V2 = int(entry2/C);
V3 = int(entry3/C);
}
if sdate != sdate[1] then {
updn_p1 = updn_tm1 / BarInterval;
}
if sdate == fdate then {
if MarketPosition == 0 and CurrentEntries == 0 then {
var1 = Highest(H, updn_tm1)[1];
if stime >= stime_from and stime <= stime_to and count < 1 then {
buy("b11",atlimit,var1*buy_r1,V1);
buy("b12",atlimit,var1*buy_r2,V2);
buy("b13",atlimit,var1*buy_r3,V3);
var3 = var1;
var4 = L;
}
}
if MarketPosition == 1 and MaxEntries == 1 then {
buy("b21",atlimit,var3*buy_r2,V2);
buy("b22",atlimit,var3*buy_r3,V3);
}
if MarketPosition == 1 and MaxEntries == 2 then {
buy("b31",atlimit,var3*buy_r3,V3);
}
if MarketPosition == 1 Then {
AVgv = AvgEntryPrice;
if L < var4 then
var4 = L;
if MaxEntries <= 2 Then{
if CurrentContracts == MaxContracts Then
exitlong("bx1_1",atlimit,var4+(var3-var4)*0.5,"",int(MaxContracts*0.5),1);
if CurrentContracts == MaxContracts Then
exitlong("bx1_2",atlimit,var4+(var3-var4)*0.75);
}
if MaxEntries == 3 Then{
if CurrentContracts == MaxContracts Then
exitlong("bx2_1",atlimit,var4+(var3-var4)*0.25,"",int(MaxContracts*0.5),1);
if CurrentContracts == MaxContracts Then
exitlong("bx2_2",atlimit,var4+(var3-var4)*0.50);
}
if stime >= 144500 Then{
exitlong("종가청산",AtMarket);
if count == 1 and MarketPosition == 0 Then{
MessageLog("분할횟수 %.f 평균단가 %.f 수익금액 %.2f 수익률",MaxEntries(1),avgv,PositionProfit(1),PositionProfit(1)/avgv);
}
}
}
}
답변 1
예스스탁 예스스탁 답변
2015-06-12 09:59:45
안녕하세요
예스스탁입니다.
청산 후 1시간이후에 다시 진입할수 있도록 지정했습니다.
청산완료후 메세지로그가 출력됩니다.
수익률은 추가진입을 하시므로
해당거래 총손익을 최대진입수량으로 나누어 1계약당 평균손익을 구하고
이값을 평균단가로 나누어 구했습니다.
input : fdate(20150610), stime_from(090000), stime_to(144500), entry1(1000000),entry2(1000000),entry3(2000000);
input : updn_tm1(15), buy_r1(0.93), buy_r2(0.9), buy_r3(0.87);
var : V1(0),V2(0),V3(0),cnt(0),count(0),updn_p1(0),AVgv(0);
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count+1;
}
if CodeCategoryEx == 11 and BasePrice < 50000 Then {
V1 = int(int(entry1/C)/10)*10;
V2 = int(int(entry2/C)/10)*10;
V3 = int(int(entry3/C)/10)*10;
} Else {
V1 = int(entry1/C);
V2 = int(entry2/C);
V3 = int(entry3/C);
}
if sdate != sdate[1] then {
updn_p1 = updn_tm1 / BarInterval;
}
if sdate == fdate then {
if MarketPosition == 0 and CurrentEntries == 0 then {
var1 = Highest(H, updn_tm1)[1];
if stime >= stime_from and stime <= stime_to and
(count == 0 or (count > 1 and TimeToMinutes(stime) >= TimeToMinutes(ExitTime(1))+60)) then {
buy("b11",atlimit,var1*buy_r1,V1);
buy("b12",atlimit,var1*buy_r2,V2);
buy("b13",atlimit,var1*buy_r3,V3);
var3 = var1;
var4 = L;
}
}
if MarketPosition == 1 and MaxEntries == 1 then {
buy("b21",atlimit,var3*buy_r2,V2);
buy("b22",atlimit,var3*buy_r3,V3);
}
if MarketPosition == 1 and MaxEntries == 2 then {
buy("b31",atlimit,var3*buy_r3,V3);
}
if MarketPosition == 1 Then {
AVgv = AvgEntryPrice;
if L < var4 then
var4 = L;
if MaxEntries <= 2 Then{
if CurrentContracts == MaxContracts Then
exitlong("bx1_1",atlimit,var4+(var3-var4)*0.5,"",int(MaxContracts*0.5),1);
if CurrentContracts == MaxContracts Then
exitlong("bx1_2",atlimit,var4+(var3-var4)*0.75);
}
if MaxEntries == 3 Then{
if CurrentContracts == MaxContracts Then
exitlong("bx2_1",atlimit,var4+(var3-var4)*0.25,"",int(MaxContracts*0.5),1);
if CurrentContracts == MaxContracts Then
exitlong("bx2_2",atlimit,var4+(var3-var4)*0.50);
}
if stime >= 144500 Then{
exitlong("종가청산",AtMarket);
}
}
}
if count >= 1 and MarketPosition == 0 and MarketPosition != MarketPosition[1] Then{
MessageLog("분할횟수 %.f 평균단가 %.f 수익금액 %.2f 수익률",MaxEntries(1),avgv,PositionProfit(1),(PositionProfit(1)/MaxContracts(1))/avgv);
}
즐거운 하루되세요
> 엠제이 님이 쓴 글입니다.
> 제목 : 추가 부탁드리겠습니다.
> 아래 수식에 대해서
매수된 수량에 대해서 매수청산이 모두 완료된 경우
MessageLog를 통해 성과를 표시한 후
1시간이 경과된 이후부터 재매수 가능하도록 로직을 보완하고 싶습니다.
ex) 9:05분 1차 매수
9:08분 2차 매수
9:10분 1차 매도
9:20분 전량 매도
MessageLong(분할횟수, 평균단가, 수익금액, 수익률)이 표시됨
10:30분 1차 매수
10:35분 1차 매도
10:40분 전량 매도
MessageLong(분할횟수, 평균단가, 수익금액, 수익률)이 표시됨
위와 같이 9:05분~9:20분까지 매매가 완료된 후 Log를 표시하고
1시간이 경과한 시점부터 재매수를 하여
10:30분~10:40분까지 매매가 완료된 후 Log를 표시함
감사합니다.
input : fdate(20150610), stime_from(090000), stime_to(144500), entry1(1000000),entry2(1000000),entry3(2000000);
input : updn_tm1(15), buy_r1(0.93), buy_r2(0.9), buy_r3(0.87);
var : V1(0),V2(0),V3(0),cnt(0),count(0),updn_p1(0),AVgv(0);
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count+1;
}
if CodeCategoryEx == 11 and BasePrice < 50000 Then {
V1 = int(int(entry1/C)/10)*10;
V2 = int(int(entry2/C)/10)*10;
V3 = int(int(entry3/C)/10)*10;
} Else {
V1 = int(entry1/C);
V2 = int(entry2/C);
V3 = int(entry3/C);
}
if sdate != sdate[1] then {
updn_p1 = updn_tm1 / BarInterval;
}
if sdate == fdate then {
if MarketPosition == 0 and CurrentEntries == 0 then {
var1 = Highest(H, updn_tm1)[1];
if stime >= stime_from and stime <= stime_to and count < 1 then {
buy("b11",atlimit,var1*buy_r1,V1);
buy("b12",atlimit,var1*buy_r2,V2);
buy("b13",atlimit,var1*buy_r3,V3);
var3 = var1;
var4 = L;
}
}
if MarketPosition == 1 and MaxEntries == 1 then {
buy("b21",atlimit,var3*buy_r2,V2);
buy("b22",atlimit,var3*buy_r3,V3);
}
if MarketPosition == 1 and MaxEntries == 2 then {
buy("b31",atlimit,var3*buy_r3,V3);
}
if MarketPosition == 1 Then {
AVgv = AvgEntryPrice;
if L < var4 then
var4 = L;
if MaxEntries <= 2 Then{
if CurrentContracts == MaxContracts Then
exitlong("bx1_1",atlimit,var4+(var3-var4)*0.5,"",int(MaxContracts*0.5),1);
if CurrentContracts == MaxContracts Then
exitlong("bx1_2",atlimit,var4+(var3-var4)*0.75);
}
if MaxEntries == 3 Then{
if CurrentContracts == MaxContracts Then
exitlong("bx2_1",atlimit,var4+(var3-var4)*0.25,"",int(MaxContracts*0.5),1);
if CurrentContracts == MaxContracts Then
exitlong("bx2_2",atlimit,var4+(var3-var4)*0.50);
}
if stime >= 144500 Then{
exitlong("종가청산",AtMarket);
if count == 1 and MarketPosition == 0 Then{
MessageLog("분할횟수 %.f 평균단가 %.f 수익금액 %.2f 수익률",MaxEntries(1),avgv,PositionProfit(1),PositionProfit(1)/avgv);
}
}
}
}
다음글
이전글