커뮤니티
문의드립니다
2017-11-24 16:52:54
161
글번호 114473
아래 수식은 매수 매수청산, 매도 매도청산 수식을 하나로 통합하였으나
수식을 실제로 적용하니 일정구간은 계속 매수진입만 또는 일정구간은 매도진입만 실행이 됩니다
구현하고자 하는 수식은
매수진입후 매수청산, 매도진입후 매도청산 순으로 반복적으로 실행하여야 합니다
예를 들자면 매수진입-- 매수청산,
매수청산 후(또는 동시에) 매도진입-- 매도청산
매도청산 후(또는 동시에) 매수진입 순으로 구현하는 방법입니다
아울러 통합된 수식에서 구현이 불가능하다면 매수수식 한가지만을 이용하여 만들어 주세요
현재 매수수식은 매수진입-매수청산만 있습니다
이것을 매수진입 - 매수청산 동시에 매도진입 - 매도청산 동시에 매수진입 순으로 진행하고자 합니다
항상 감사합니다
input : b1(9),b2(9),X1(9),X2(9),진입눌림(3),진입돌파(1),청산눌림(3),청산돌파(1),거래횟수(20),시작시간(090000) ;
var : T1(0),entry(0),LL(0),EH(0),E1(0),H1(0),i1(0),S1(0),L1(0),V1(0);
var : sHH(0),sEL(0),sE1(0),sH1(0),si1(0),sS1(0),sL1(0),sV1(0);
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime > 시작시간 and stime[1] < 시작시간) Then{
T1 = TotalTrades;
E1 = 0;
LL = L;
}
if stime >= 시작시간 then{
if L < LL Then
LL = L;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 Then{
if E1 == 0 and C >= LL+PriceScale*B1 and C[1] < LL+PriceScale*B1 Then{
E1 = 1;
H1 = H;
i1 = index;
V1 = LL; //시작점 종가
}
if E1 == 1 and index > i1 then{
if H > H1 Then
H1 = H;
#저가가 시작봉종가보다 클때만 눌림체크
if L >= V1 and L <= H1-PriceScale*진입눌림 Then{
E1 = 2;
i1 = index;
S1 = H1;
}
}
//시작점 종가보다 낮은 가격이 발생하면 초기화
if E1 >= 1 and L < V1 Then{
E1 = 0;
LL = L;
}
if E1 == 2 and index > i1 and C >= S1+PriceScale*진입돌파 Then{
buy("b1");
}
}
if TotalTrades > TotalTrades[1] Then{
E1 = 0;
LL = L;
}
if L < LL Then
LL = L;
if MarketPosition == 0 and entry >= 1 and entry < 거래횟수 Then{
if E1 == 0 and C >= LL+PriceScale*B2 and C[1] < LL+PriceScale*B2 Then{
E1 = 1;
H1 = H;
i1 = index;
V1 = LL; //시작점 종가
}
if E1 == 1 and index > i1 then{
if H > H1 Then
H1 = H;
#저가가 시작봉종가보다 클때만 눌림체크
if L >= V1 and L <= H1-PriceScale*진입눌림 Then{
E1 = 2;
i1 = index;
S1 = H1;
}
}
//시작점 종가보다 낮은 가격이 발생하면 초기화
if E1 >= 1 and L < V1 Then{
E1 = 0;
LL = L;
}
if E1 == 2 and index > i1 and C >= S1+PriceScale*진입돌파 Then{
buy("b2");
}
}
if MarketPosition == 1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
EH = H;
E1 = 0;
}
if H > EH Then{
EH = H;
E1 = 0;
}
if E1 == 0 and C <= EH-PriceScale*X1 Then{
E1 = 1;
L1 = L;
i1 = index;
}
if E1 == 1 and index > i1 Then{
if L < L1 Then
L1 = L;
if H >= L1+PriceScale*청산눌림 Then{
E1 = 2;
I1 = index;
S1 = L1;
}
}
if E1 == 2 and index > i1 and C <= S1-PriceScale*청산돌파 Then{
exitlong("bx1");
E1 = 0;
}
}
}
if MarketPosition == 1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
EH = H;
E1 = 0;
}
if H > EH Then{
EH = H;
E1 = 0;
}
if E1 == 0 and C <= EH-PriceScale*X2 Then{
E1 = 1;
L1 = L;
i1 = index;
}
if E1 == 1 and index > i1 Then{
if L < L1 Then
L1 = L;
if H >= L1+PriceScale*청산눌림 Then{
E1 = 2;
I1 = index;
S1 = L1;
}
}
if E1 == 2 and index > i1 and C <= S1-PriceScale*청산돌파 Then{
exitlong("bx2");
E1 = 0;
}
}
}
}
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime > 시작시간 and stime[1] < 시작시간) Then{
T1 = TotalTrades;
sHH = H;
sE1 = 0;
}
if stime >= 시작시간 then{
if H > sHH Then
sHH = H;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 Then{
if sE1 == 0 and C <= sHH-PriceScale*B1 and C[1] > sHH-PriceScale*B1 Then{
sE1 = 1;
sL1 = L;
si1 = index;
sV1 = sHH;
}
if sE1 == 1 and index > si1 then{
if L < sL1 Then
sL1 = L;
if H <= sV1 and H >= sH1+PriceScale*진입눌림 Then{
sE1 = 2;
si1 = index;
sS1 = sL1;
}
}
if sE1 >= 1 and H > sV1 Then{
sE1 = 0;
sHH = H;
}
if sE1 == 2 and index > si1 and C <= sS1-PriceScale*진입돌파 Then{
sell("s1");
}
}
if TotalTrades > TotalTrades[1] Then{
sE1 = 0;
sHH = H;
}
if H > sHH Then
sHH = H;
if MarketPosition == 0 and entry >= 1 and entry < 거래횟수 Then{
if sE1 == 0 and C <= sHH-PriceScale*B2 and C[1] > sHH-PriceScale*B2 Then{
sE1 = 1;
sL1 = L;
si1 = index;
sV1 = sHH; //시작점 종가
}
if sE1 == 1 and index > si1 then{
if L < sL1 Then
sL1 = L;
if H <= sV1 and H >= sL1+PriceScale*진입눌림 Then{
sE1 = 2;
si1 = index;
sS1 = sL1;
}
}
if sE1 >= 1 and H > sV1 Then{
sE1 = 0;
sHH = H;
}
if sE1 == 2 and index > si1 and C <= sS1-PriceScale*진입돌파 Then{
sell("s2");
}
}
if MarketPosition == -1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
sEL = L;
sE1 = 0;
}
if L < sEL Then{
sEL = L;
sE1 = 0;
}
if sE1 == 0 and C >= sEL+PriceScale*X1 Then{
sE1 = 1;
sH1 = H;
si1 = index;
}
if sE1 == 1 and index > si1 Then{
if H > sH1 Then
sH1 = H;
if L <= sH1-PriceScale*청산눌림 Then{
sE1 = 2;
sI1 = index;
sS1 = sH1;
}
}
if sE1 == 2 and index > si1 and C >= sS1+PriceScale*청산돌파 Then{
ExitShort("sx1");
sE1 = 0;
}
}
}
if MarketPosition == -1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
sEL = L;
sE1 = 0;
}
if L < sEL Then{
sEL = L;
sE1 = 0;
}
if sE1 == 0 and C >= sEL+PriceScale*X2 Then{
sE1 = 1;
sH1 = H;
si1 = index;
}
if sE1 == 1 and index > si1 Then{
if H > sH1 Then
sH1 = H;
if L <= sH1-PriceScale*청산눌림 Then{
sE1 = 2;
sI1 = index;
sS1 = sH1;
}
}
if sE1 == 2 and index > si1 and C >= sS1+PriceScale*청산돌파 Then{
ExitShort("sx2");
sE1 = 0;
}
}
}
}
답변 1
예스스탁 예스스탁 답변
2017-11-28 10:26:58
안녕하세요
예스스탁입니다.
죄송하지만 수식을 어떻게 수정해 드려야 할지 모르겠습니다.
매수-매수청산식을 매수청산시 매도진입을 같이하게
매수진입시 매도청산을 병행하게 수정해 드립니다.
해당식은 사용자분이 이후에 수정해 보셔야 합니다.
합치는 내용은 전반적으로 다시 작성해야 하는데
식 작성에 시간이 많이 결려 업무상 작성해 드리기 어렵습니다.
도움을 드리지 못해 죄송합니다.
input : b1(9),b2(9),X1(9),X2(9),진입눌림(3),진입돌파(1),청산눌림(3),청산돌파(1),거래횟수(20),시작시간(090000) ;
var : T1(0),entry(0),LL(0),EH(0),E1(0),H1(0),i1(0),S1(0),L1(0),V1(0);
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime > 시작시간 and stime[1] < 시작시간) Then{
T1 = TotalTrades;
E1 = 0;
LL = L;
}
if stime >= 시작시간 then{
if L < LL Then
LL = L;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition <= 0 and entry == 0 Then{
if E1 == 0 and C >= LL+PriceScale*B1 and C[1] < LL+PriceScale*B1 Then{
E1 = 1;
H1 = H;
i1 = index;
V1 = LL; //시작점 종가
}
if E1 == 1 and index > i1 then{
if H > H1 Then
H1 = H;
#저가가 시작봉종가보다 클때만 눌림체크
if L >= V1 and L <= H1-PriceScale*진입눌림 Then{
E1 = 2;
i1 = index;
S1 = H1;
}
}
//시작점 종가보다 낮은 가격이 발생하면 초기화
if E1 >= 1 and L < V1 Then{
E1 = 0;
LL = L;
}
if E1 == 2 and index > i1 and C >= S1+PriceScale*진입돌파 Then{
buy("b1");
}
}
if TotalTrades > TotalTrades[1] Then{
E1 = 0;
LL = L;
}
if L < LL Then
LL = L;
if MarketPosition <= 0 and entry >= 1 and entry < 거래횟수 Then{
if E1 == 0 and C >= LL+PriceScale*B2 and C[1] < LL+PriceScale*B2 Then{
E1 = 1;
H1 = H;
i1 = index;
V1 = LL; //시작점 종가
}
if E1 == 1 and index > i1 then{
if H > H1 Then
H1 = H;
#저가가 시작봉종가보다 클때만 눌림체크
if L >= V1 and L <= H1-PriceScale*진입눌림 Then{
E1 = 2;
i1 = index;
S1 = H1;
}
}
//시작점 종가보다 낮은 가격이 발생하면 초기화
if E1 >= 1 and L < V1 Then{
E1 = 0;
LL = L;
}
if E1 == 2 and index > i1 and C >= S1+PriceScale*진입돌파 Then{
buy("b2");
}
}
if MarketPosition == 1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
EH = H;
E1 = 0;
}
if H > EH Then{
EH = H;
E1 = 0;
}
if E1 == 0 and C <= EH-PriceScale*X1 Then{
E1 = 1;
L1 = L;
i1 = index;
}
if E1 == 1 and index > i1 Then{
if L < L1 Then
L1 = L;
if H >= L1+PriceScale*청산눌림 Then{
E1 = 2;
I1 = index;
S1 = L1;
}
}
if E1 == 2 and index > i1 and C <= S1-PriceScale*청산돌파 Then{
sell("bx1");
E1 = 0;
}
}
}
if MarketPosition == 1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
EH = H;
E1 = 0;
}
if H > EH Then{
EH = H;
E1 = 0;
}
if E1 == 0 and C <= EH-PriceScale*X2 Then{
E1 = 1;
L1 = L;
i1 = index;
}
if E1 == 1 and index > i1 Then{
if L < L1 Then
L1 = L;
if H >= L1+PriceScale*청산눌림 Then{
E1 = 2;
I1 = index;
S1 = L1;
}
}
if E1 == 2 and index > i1 and C <= S1-PriceScale*청산돌파 Then{
sell("bx2");
E1 = 0;
}
}
}
}
즐거운 하루되세요
> 남산 님이 쓴 글입니다.
> 제목 : 문의드립니다
> 아래 수식은 매수 매수청산, 매도 매도청산 수식을 하나로 통합하였으나
수식을 실제로 적용하니 일정구간은 계속 매수진입만 또는 일정구간은 매도진입만 실행이 됩니다
구현하고자 하는 수식은
매수진입후 매수청산, 매도진입후 매도청산 순으로 반복적으로 실행하여야 합니다
예를 들자면 매수진입-- 매수청산,
매수청산 후(또는 동시에) 매도진입-- 매도청산
매도청산 후(또는 동시에) 매수진입 순으로 구현하는 방법입니다
아울러 통합된 수식에서 구현이 불가능하다면 매수수식 한가지만을 이용하여 만들어 주세요
현재 매수수식은 매수진입-매수청산만 있습니다
이것을 매수진입 - 매수청산 동시에 매도진입 - 매도청산 동시에 매수진입 순으로 진행하고자 합니다
항상 감사합니다
input : b1(9),b2(9),X1(9),X2(9),진입눌림(3),진입돌파(1),청산눌림(3),청산돌파(1),거래횟수(20),시작시간(090000) ;
var : T1(0),entry(0),LL(0),EH(0),E1(0),H1(0),i1(0),S1(0),L1(0),V1(0);
var : sHH(0),sEL(0),sE1(0),sH1(0),si1(0),sS1(0),sL1(0),sV1(0);
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime > 시작시간 and stime[1] < 시작시간) Then{
T1 = TotalTrades;
E1 = 0;
LL = L;
}
if stime >= 시작시간 then{
if L < LL Then
LL = L;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 Then{
if E1 == 0 and C >= LL+PriceScale*B1 and C[1] < LL+PriceScale*B1 Then{
E1 = 1;
H1 = H;
i1 = index;
V1 = LL; //시작점 종가
}
if E1 == 1 and index > i1 then{
if H > H1 Then
H1 = H;
#저가가 시작봉종가보다 클때만 눌림체크
if L >= V1 and L <= H1-PriceScale*진입눌림 Then{
E1 = 2;
i1 = index;
S1 = H1;
}
}
//시작점 종가보다 낮은 가격이 발생하면 초기화
if E1 >= 1 and L < V1 Then{
E1 = 0;
LL = L;
}
if E1 == 2 and index > i1 and C >= S1+PriceScale*진입돌파 Then{
buy("b1");
}
}
if TotalTrades > TotalTrades[1] Then{
E1 = 0;
LL = L;
}
if L < LL Then
LL = L;
if MarketPosition == 0 and entry >= 1 and entry < 거래횟수 Then{
if E1 == 0 and C >= LL+PriceScale*B2 and C[1] < LL+PriceScale*B2 Then{
E1 = 1;
H1 = H;
i1 = index;
V1 = LL; //시작점 종가
}
if E1 == 1 and index > i1 then{
if H > H1 Then
H1 = H;
#저가가 시작봉종가보다 클때만 눌림체크
if L >= V1 and L <= H1-PriceScale*진입눌림 Then{
E1 = 2;
i1 = index;
S1 = H1;
}
}
//시작점 종가보다 낮은 가격이 발생하면 초기화
if E1 >= 1 and L < V1 Then{
E1 = 0;
LL = L;
}
if E1 == 2 and index > i1 and C >= S1+PriceScale*진입돌파 Then{
buy("b2");
}
}
if MarketPosition == 1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
EH = H;
E1 = 0;
}
if H > EH Then{
EH = H;
E1 = 0;
}
if E1 == 0 and C <= EH-PriceScale*X1 Then{
E1 = 1;
L1 = L;
i1 = index;
}
if E1 == 1 and index > i1 Then{
if L < L1 Then
L1 = L;
if H >= L1+PriceScale*청산눌림 Then{
E1 = 2;
I1 = index;
S1 = L1;
}
}
if E1 == 2 and index > i1 and C <= S1-PriceScale*청산돌파 Then{
exitlong("bx1");
E1 = 0;
}
}
}
if MarketPosition == 1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
EH = H;
E1 = 0;
}
if H > EH Then{
EH = H;
E1 = 0;
}
if E1 == 0 and C <= EH-PriceScale*X2 Then{
E1 = 1;
L1 = L;
i1 = index;
}
if E1 == 1 and index > i1 Then{
if L < L1 Then
L1 = L;
if H >= L1+PriceScale*청산눌림 Then{
E1 = 2;
I1 = index;
S1 = L1;
}
}
if E1 == 2 and index > i1 and C <= S1-PriceScale*청산돌파 Then{
exitlong("bx2");
E1 = 0;
}
}
}
}
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime > 시작시간 and stime[1] < 시작시간) Then{
T1 = TotalTrades;
sHH = H;
sE1 = 0;
}
if stime >= 시작시간 then{
if H > sHH Then
sHH = H;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 Then{
if sE1 == 0 and C <= sHH-PriceScale*B1 and C[1] > sHH-PriceScale*B1 Then{
sE1 = 1;
sL1 = L;
si1 = index;
sV1 = sHH;
}
if sE1 == 1 and index > si1 then{
if L < sL1 Then
sL1 = L;
if H <= sV1 and H >= sH1+PriceScale*진입눌림 Then{
sE1 = 2;
si1 = index;
sS1 = sL1;
}
}
if sE1 >= 1 and H > sV1 Then{
sE1 = 0;
sHH = H;
}
if sE1 == 2 and index > si1 and C <= sS1-PriceScale*진입돌파 Then{
sell("s1");
}
}
if TotalTrades > TotalTrades[1] Then{
sE1 = 0;
sHH = H;
}
if H > sHH Then
sHH = H;
if MarketPosition == 0 and entry >= 1 and entry < 거래횟수 Then{
if sE1 == 0 and C <= sHH-PriceScale*B2 and C[1] > sHH-PriceScale*B2 Then{
sE1 = 1;
sL1 = L;
si1 = index;
sV1 = sHH; //시작점 종가
}
if sE1 == 1 and index > si1 then{
if L < sL1 Then
sL1 = L;
if H <= sV1 and H >= sL1+PriceScale*진입눌림 Then{
sE1 = 2;
si1 = index;
sS1 = sL1;
}
}
if sE1 >= 1 and H > sV1 Then{
sE1 = 0;
sHH = H;
}
if sE1 == 2 and index > si1 and C <= sS1-PriceScale*진입돌파 Then{
sell("s2");
}
}
if MarketPosition == -1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
sEL = L;
sE1 = 0;
}
if L < sEL Then{
sEL = L;
sE1 = 0;
}
if sE1 == 0 and C >= sEL+PriceScale*X1 Then{
sE1 = 1;
sH1 = H;
si1 = index;
}
if sE1 == 1 and index > si1 Then{
if H > sH1 Then
sH1 = H;
if L <= sH1-PriceScale*청산눌림 Then{
sE1 = 2;
sI1 = index;
sS1 = sH1;
}
}
if sE1 == 2 and index > si1 and C >= sS1+PriceScale*청산돌파 Then{
ExitShort("sx1");
sE1 = 0;
}
}
}
if MarketPosition == -1 Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
sEL = L;
sE1 = 0;
}
if L < sEL Then{
sEL = L;
sE1 = 0;
}
if sE1 == 0 and C >= sEL+PriceScale*X2 Then{
sE1 = 1;
sH1 = H;
si1 = index;
}
if sE1 == 1 and index > si1 Then{
if H > sH1 Then
sH1 = H;
if L <= sH1-PriceScale*청산눌림 Then{
sE1 = 2;
sI1 = index;
sS1 = sH1;
}
}
if sE1 == 2 and index > si1 and C >= sS1+PriceScale*청산돌파 Then{
ExitShort("sx2");
sE1 = 0;
}
}
}
}