답변완료
부탁 드립니다.
항상 도움에 감사 드립니다.
틱봉용 수식으로 작성 해본 것입니다.
어딘가에 오류가 있어 보입니다.
수정 부탁 드립니다.
질문수식)
input:p(10),sig(30);
var1=obv();
var2=ma(var1,p);
var3=var1-var2;
var4=ma(var3,sig);
틱봉용 수식)
input : ntime(6),P(60),sig(5);
var : S1(0),D1(0),TM(0),TF(0),cnt(0),sum1(0),sum2(0);
var : v2(0),v4(0),pre(0),C1(0),idx(0),vv(0);
Array : v1[100](0),v3[100](0);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
idx = 0;
}
Else
idx = idx+1;
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = idx%ntime;
if Bdate != bdate[1] or (TF < TF[1] and Bdate == Bdate[1]) Then
{
// idx = idx+1;
C1 = C[1];
vv = 0;
pre = v1[0][1];
For cnt = 1 to 99
{
v1[cnt] = v1[cnt-1][1];
v3[cnt] = v3[cnt-1][1];
}
}
vv = vv + v;
if C > C1 Then
v1[0] = pre + vv;
else if C < C1 Then
v1[0] = pre - vv;
else
v1[0] = pre;
if idx >= P then
{
sum1 = 0;
For cnt = 0 to P-1
{
sum1 = sum1+v1[cnt];
}
v2 = sum1/p;
v3[0] = v1[0]-v2;
}
if idx >= P+sig then
{
sum2 = 0;
For cnt = 0 to sig-1
{
sum2 = sum2+v3[cnt];
}
v4 = sum2/sig;
Plot1(v4);
}
}
PlotBaseLine1(0);
2021-10-28
603
글번호 153226
지표
답변완료
키움지표예스로 변경부탁드립니다
질문1
키움수식
기간=14
======================
M1=Max(C,O);
M2=Min(C,O);
M3=Highest(M1,기간);
M4=Lowest(M2,기간);
M5=(M3+M4)/2;
B=valuewhen(1, M5<M5(1), C);
ma(B,35)
========================
위수식을 예스로 변경하면 다음과같습니다
input:기간(14);
var:M1(0),M2(0),M3(0),M4(0),M5(0),M6(0);
M1=Max(C,O);
M2=Min(C,O);
M3=Highest(M1,기간);
M4=Lowest(M2,기간);
M5=(M3+M4)/2;
if M5<M5[1] Then
Value1=C;
M6=ma(Value1,35);
Plot1(M6);
위와같이하면 키움과예스의 수치가 정확히 일치를 합니다만
M1=Max(C,O);
M2=Min(C,O);
M3=Highest(M1,기간);
M4=Lowest(M2,기간);
M5=(M3+M4)/2;
B=valuewhen(1, M5<M5(1), C);
D=ma(B,35);
M11=Max(C,O);
M12=Min(C,O);
M13=Highest(M11,기간);
M14=Lowest(M12,기간);
M15=(M13+M14)/2;
B1=valuewhen(1, M15<M15(1), C);
D1=ma(B1,35);
E=(D+D1)/2:
이렇게 키움수식이 되었을시에 예스로변경하면
input:기간(14);
var:M1(0),M2(0),M3(0),M4(0),M5(0),M6(0);
M1=Max(C,O);
M2=Min(C,O);
M3=Highest(M1,기간);
M4=Lowest(M2,기간);
M5=(M3+M4)/2;
if M5>M5[1] Then
Value1=C;
M6=ma(Value1,35);
var:M11(0),M12(0),M13(0),M14(0),M15(0),M16(0),M17(0);
M11=Max(C,O);
M12=Min(C,O);
M13=Highest(M11,기간);
M14=Lowest(M12,기간);
M15=(M13+M14)/2;
if M15<M15[1] Then
Value2=C;
M16=ma(Value2,35);
M17=(M6+M16)/2;
Plot1(M17);
각각하나씩은 수치가 같은데요 두개의식을 합치면 수치가 달라집니다
질문2
또한 종목검색으로 만들시
input:기간(14);
var:M1(0),M2(0),M3(0),M4(0),M5(0),M6(0);
M1=Max(C,O);
M2=Min(C,O);
M3=Highest(M1,기간);
M4=Lowest(M2,기간);
M5=(M3+M4)/2;
if M5>M5[1] Then
Value1=C;
M6=ma(Value1,35);
var:M11(0),M12(0),M13(0),M14(0),M15(0),M16(0),M17(0);
M11=Max(C,O);
M12=Min(C,O);
M13=Highest(M11,기간);
M14=Lowest(M12,기간);
M15=(M13+M14)/2;
if M15<M15[1] Then
Value2=C;
M16=ma(Value2,35);
M17=(M6+M16)/2;
if crossup(C,M17) then find(1);
분명히 종목들이 존재를 하는데도 검색이 안됩니다
열흘이상 고민해봐도 해답을 모르겠습니다
도움이 절실합니다 부탁드리겠습니다
감사합니다 수고하세요
2021-10-28
933
글번호 153217
지표
답변완료
문의드립니다.
안녕하세요.
1분봉에서 일봉 이평선 가격을 기준으로 매수/매도하는 수식을 작성하려고 합니다.
거의 일봉으로만 거래를 하다보니 분봉 시스템에 익숙치 않아서 도움을 부탁드립니다.
시스템 제작에 많은 도움을 주셔서 항상 감사드립니다.
전략은 개장 후 시가가 밀리면 1% 하락 시마다 분할 매수(현재는 4회만 표시하였으나 횟수 제한 없이 매수할 예정)한 후 평균가 대비 5% 상승 시 매도하는 전략입니다.
단 일봉 이평선(5,10,20,60) 중 현재가격 바로 아래에 있는 일봉이평선을 기준으로 삼아서 그 이평선 도달 전까지만 매수하고 이평선을 이탈(-2%)하면 손절할 예정이며, 일 1회만 거래하려고 합니다.
아래 수식으로 작성을 해봤는데 수정 부탁드립니다. 좋은 하루 보내세요.
input : p5(0), p10(0),p20(20), p60(60),p120(120),p240(240);
input : dayperiod5(5), dayperiod10(10), dayperiod20(20),dayperiod60(60);
var : cond1(False), cond11(False), cond12(False);
var : ma5(0),ma10(0),ma20(0),ma60(0),ma120(0),ma240(0), 이평(0), count(0);
var : cnt(0),sum5(0), sum10(0), sum20(0), sum60(0), daymav(0), daymav5(0), daymav10(0), daymav20(0), daymav60(0);
var : min1(0), min2(0), min3(0), min4(0);
if Bdate != Bdate[1] Then
{
Cond1 = False; #당일조건만족여부
count = 0;
}
#일봉 이동평균계산
sum5 = 0;
For cnt = 0 to dayPeriod5-1
{
sum5 = sum5 + DayClose(cnt);
}
daymav5 = sum5/dayPeriod5; // 현재 20일선
sum10 = 0;
For cnt = 0 to dayPeriod10-1
{
sum10 = sum10 + DayClose(cnt);
}
daymav10 = sum10/dayPeriod10; // 현재 20일선
sum20 = 0;
For cnt = 0 to dayPeriod20-1
{
sum20 = sum20 + DayClose(cnt);
}
daymav20 = sum20/dayPeriod20; // 현재 20일선
sum60 = 0;
For cnt = 0 to dayPeriod60-1
{
sum60 = sum60 + DayClose(cnt);
}
daymav60 = sum60/dayPeriod60; // 현재 20일선
// 분봉 종가와 일봉이평선과의 간격 확인
min1 = nthminlist(1,C-daymav5,C-daymav10,C-daymav20,C-daymav60);
min2 = nthminlist(2,C-daymav5,C-daymav10,C-daymav20,C-daymav60);
min3 = nthminlist(3,C-daymav5,C-daymav10,C-daymav20,C-daymav60);
min4 = nthminlist(4,C-daymav5,C-daymav10,C-daymav20,C-daymav60);
// 종가가 모든 이평선보다 위에 있으면 daymav를 제일 높은 가격의 이평선선택
if min1>0 Then daymav = NthMaxList(1, daymav5, daymav10, daymav20, daymav60);
// 1개의 이평선이 종가보다 높은 경우, 2번재 높은 가격의 이평선을 선택
Else if min2 > 0 Then daymav = NthMaxList(2, daymav5, daymav10, daymav20, daymav60);
Else if min3 > 0 Then daymav = NthMaxList(3, daymav5, daymav10, daymav20, daymav60);
Else if min4 > 0 Then daymav = NthMaxList(4, daymav5, daymav10, daymav20, daymav60);
Else daymav = 0;
If cond1 == False and MarketPosition == 0 and C < DayOpen(0) and C>daymav and count< 1 Then
{
Buy("b1", AtLimit, DayOpen(0)*0.99,1);
}
If cond1 == False and MarketPosition == 1 and C < DayOpen(0) and C>daymav and count< 2 Then
{
Buy("b2", AtLimit, DayOpen(0)*0.98,1);
}
If cond1 == False and MarketPosition == 1 and C < DayOpen(0) and C>daymav and count< 3 Then
{
Buy("b3", AtLimit, DayOpen(0)*0.97,1);
}
If cond1 == False and MarketPosition == 1 and C < DayOpen(0) and C>daymav and count< 4 Then
{
Buy("b4", AtLimit, DayOpen(0)*0.96,1);
}
If MarketPosition == 1 then
{
// 이평선 2% 이탈 시 손절
ExitLong("bx1",AtLimit,daymav*0.98,"",1,2);
//익절(5%)
ExitLong("bx11",AtLimit,AvgEntryPrice*1.05,"",1,2);
}
If CurrentEntries<CurrentEntries[1] Then
count = count + 1;
2021-10-27
615
글번호 153208
시스템
답변완료
문의드립니다.
제가 문의를 정확히 드리지 못해 죄송합니다.
아래 수식으로 데모해보니 맞지않는 부분이 있습니다.
확인부탁드립니다.
30분봉이 기준이고 거기에 6분봉 조건이 같은 방향이면 매수 매도 진입하는 원칙입니다.
30분봉이 매수신호 나와있으면 6분봉은 매수로만 진입이 되야 합니다.
30분봉이 매도신호 나와있으면 6분봉은 매도로만 진입이 되야 합니다.
* 30분봉
- 매수 신호 조건
1. 30분봉이 이전 10번째 봉 고가 위에 있을 때
단, 현재 캔들이 자기 시가를 깰 때와 앞 캔들의 저가를 깰 때는 매수 신호가 사라지고 다시 회복하면 매수 신호가 나오도록 해주세요.
2. 30분봉이 이전 10번째 봉 고가를 돌파할 때
단, 10번째 봉 고가를 깰 때 매수 신호가 사라지고 다시 돌파하면 매수 신호가 나오도록 해주세요.
- 매도 신호 조건
1. 30분봉이 이전 10번째 봉 저가 아래에 있을 때
단, 현재 캔들이 자기 시가를 돌파할 때와 앞 캔들의 고가를 돌파할 때는 매도 신호가 사라지고 다시 회복하면 매도 신호가 나오도록 해주세요.
2. 30분봉이 이전 10번째 봉 저가를 돌파(깰)할 때
단, 10번째 봉 저가를 돌파할 때 매도 신호가 사라지고 다시 깨면 매도 신호가 나오도록 해주세요.
* 6분봉
- 매수 신호 및 매수 조건
1. 이전 10개 캔들의 최고가를 돌파할 때 매수 신호 및 즉시 매수.
2. 이미 이전 10개 캔들 위에서 시작할 때는 앞 캔들 고가를 돌파할 때 매수 신호 및 즉시 매수
- 매도 신호 및 매도 조건
1. 이전 10개 캔들의 최저가를 돌파할 때 매도 신호 및 즉시 매도.
2. 이미 이전 10개 캔들 아래에서 시작할 때는 앞 캔들 저가를 돌파할 때 매도 신호 및 즉시 매도
## 종가에 진입하는 식에서는 매수는 양봉에만, 매도는 음봉에만 진입하도록 해주세요.
이번 데모에서 이런 문제가 생겨서 남깁니다.
1. 돌파 즉시 매수가 들어가지 않습니다.
2. 30분봉이 30분동안 매수 신호를 유지하고 있는 경우, 6분봉은 이전 5개 캔들 중 최고가를 돌파할 때만 매수 신호가 나오며 매수 진입해야 합니다. 6분봉에서 매도 신호가 나오더라도
30분봉은 매수 신호이니 매도 진입은 하지 않아야 맞는데, 매도 진입이 되고 있습니다.
3. 6분봉에서 이전 10개 캔들의 최고가를 돌파하지 않았는데 매수가 들어가고 있습니다.
아래 수식에서 수정할 부분 확인 수정 부탁드립니다.
감사합니다~~
1 즉시진입
input : ntime1(6),ntime2(30),n(10);
input : StartTime(222500),EndTime(010000);
input : 익절틱수(50),손절틱수(50);
var : S1(0),D1(0),TM(0),TF1(0),TF2(0),cnt(0),HH(0),LL(0);
var : Tcond(false),BE1(False),BE2(False),SE1(False),SE2(False);
Array : H1[50](0),L1[50](0),H2[50](0),L2[50](0);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
Tcond = true;
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF1 = TM%ntime1;
TF2 = TM%ntime2;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime1 > 1 and TF1 < TF1[1]) or
(Bdate == Bdate[1] and ntime1 > 1 and TM >= TM[1]+ntime1) or
(Bdate == Bdate[1] and ntime1 == 1 and TM > TM[1]) Then
{
H1[0] = H;
L1[0] = L;
For cnt = 1 to 49
{
H1[cnt] = H1[cnt-1][1];
L1[cnt] = L1[cnt-1][1];
}
}
if H1[0] > 0 and H > H1[0] Then
H1[0] = H;
if L1[0] > 0 and L < L1[0] Then
L1[0] = L;
HH = 0;
LL = 0;
if H1[n] > 0 and L1[n] > 0 Then
{
For cnt = 1 to N
{
if HH == 0 or (HH > 0 and H1[cnt] > HH) Then
HH = H1[cnt];
if LL == 0 or (LL > 0 and L1[cnt] < LL) Then
LL = L1[cnt];
}
}
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime2 > 1 and TF2 < TF2[1]) or
(Bdate == Bdate[1] and ntime2 > 1 and TM >= TM[1]+ntime2) or
(Bdate == Bdate[1] and ntime2 == 1 and TM > TM[1]) Then
{
H2[0] = H;
L2[0] = L;
For cnt = 1 to 49
{
H2[cnt] = H2[cnt-1][1];
L2[cnt] = L2[cnt-1][1];
}
BE1 = False;
BE2 = False;
SE1 = False;
SE2 = False;
}
if H2[0] > 0 and H > H2[0] Then
H2[0] = H;
if L2[0] > 0 and L < L2[0] Then
L2[0] = L;
if Tcond == true Then
{
if MarketPosition <= 0 and HH > 0 Then
Buy("b1",AtStop,HH+PriceScale*1);
if MarketPosition <= 0 and H2[n] > 0 Then
Buy("b2",AtStop,H2[n]+PriceScale*1);
if MarketPosition >= 0 and LL > 0 Then
Sell("s1",AtStop,LL-PriceScale*1);
if MarketPosition >= 0 and L2[n] > 0 Then
Sell("s2",AtStop,L2[n]-PriceScale*1);
if MarketPosition <= 0 and HH > 0 and H2[n] > 0 Then
Buy("b3",AtStop,max(HH,H2[n])+PriceScale*1);
if MarketPosition >= 0 and L1[n] > 0 and L2[n] > 0 Then
Sell("s3",AtStop,min(LL,L2[n])-PriceScale*1);
if H >= HH+PriceScale*1 Then
BE1 = true;
if H >= H2[n]+PriceScale*1 Then
BE2 = true;
if L <= LL-PriceScale*1 Then
SE1 = true;
if L <= H2[n]+PriceScale*1 Then
SE2 = true;
if BE1 == true and BE2 == False Then
Buy("b41",AtStop,H2[n]+PriceScale*1);
if BE1 == False and BE2 == true Then
Buy("b42",AtStop,HH+PriceScale*1);
if SE1 == true and SE2 == False Then
Sell("s41",AtStop,L2[n]-PriceScale*1);
if SE1 == False and SE2 == true Then
Sell("s42",AtStop,LL+PriceScale*1);
}
}
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
2. 종가진입
input : ntime1(6),ntime2(30),n(10);
input : StartTime(222500),EndTime(010000);
input : 익절틱수(50),손절틱수(50);
var : S1(0),D1(0),TM(0),TF1(0),TF2(0),cnt(0),HH(0),LL(0);
var : Tcond(false),BE1(False),BE2(False),SE1(False),SE2(False);
Array : H1[50](0),L1[50](0),H2[50](0),L2[50](0);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
Tcond = true;
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF1 = TM%ntime1;
TF2 = TM%ntime2;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime1 > 1 and TF1 < TF1[1]) or
(Bdate == Bdate[1] and ntime1 > 1 and TM >= TM[1]+ntime1) or
(Bdate == Bdate[1] and ntime1 == 1 and TM > TM[1]) Then
{
H1[0] = H;
L1[0] = L;
For cnt = 1 to 49
{
H1[cnt] = H1[cnt-1][1];
L1[cnt] = L1[cnt-1][1];
}
}
if H1[0] > 0 and H > H1[0] Then
H1[0] = H;
if L1[0] > 0 and L < L1[0] Then
L1[0] = L;
HH = 0;
LL = 0;
if H1[n] > 0 and L1[n] > 0 Then
{
For cnt = 1 to N
{
if HH == 0 or (HH > 0 and H1[cnt] > HH) Then
HH = H1[cnt];
if LL == 0 or (LL > 0 and L1[cnt] < LL) Then
LL = L1[cnt];
}
}
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime2 > 1 and TF2 < TF2[1]) or
(Bdate == Bdate[1] and ntime2 > 1 and TM >= TM[1]+ntime2) or
(Bdate == Bdate[1] and ntime2 == 1 and TM > TM[1]) Then
{
H2[0] = H;
L2[0] = L;
For cnt = 1 to 49
{
H2[cnt] = H2[cnt-1][1];
L2[cnt] = L2[cnt-1][1];
}
BE1 = False;
BE2 = False;
SE1 = False;
SE2 = False;
}
if H2[0] > 0 and H > H2[0] Then
H2[0] = H;
if L2[0] > 0 and L < L2[0] Then
L2[0] = L;
if Tcond == true Then
{
if MarketPosition <= 0 and HH > 0 and C > HH+PriceScale*1 Then
Buy("b1");
if MarketPosition <= 0 and H2[n] > 0 and C > H2[n]+PriceScale*1 Then
Buy("b2");
if MarketPosition >= 0 and LL > 0 and C < LL-PriceScale*1 Then
Sell("s1");
if MarketPosition >= 0 and L2[n] > 0 and C < L2[n]-PriceScale*1 Then
Sell("s2");
if MarketPosition <= 0 and HH > 0 and H2[n] > 0 and C > max(HH,H2[n])+PriceScale*1 Then
Buy("b3");
if MarketPosition >= 0 and L1[n] > 0 and L2[n] > 0 and C < min(LL,L2[n])-PriceScale*1 Then
Sell("s3");
if C >= HH+PriceScale*1 Then
BE1 = true;
if C >= H2[n]+PriceScale*1 Then
{
BE2 = true;
}
if C <= LL-PriceScale*1 Then
SE1 = true;
if C <= H2[n]+PriceScale*1 Then
SE2 = true;
if BE1 == true and BE2 == true and (BE1[1] == False or BE2[1] == False) Then
Buy("b4");
if SE1 == true and SE2 == true and (SE1[1] == true or SE2 == False) Then
Sell("s4");
}
}
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
2021-10-28
569
글번호 153207
시스템