예스스탁
예스스탁 답변
2021-10-26 14:09:14
안녕하세요
예스스탁입니다.
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);
Array : H1[50](0),L1[50](0),H2[50](0),L2[50](0);
var : Tcond(false);
#지정한 종료시간 이후의 첫봉일때 Tcond는 False
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
#지정한 시작시간 이후의 첫봉일때 Tcond는 true
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에 시간을 분으로 환산한 값을 저장
S1 = TimeToMinutes(stime);
#D1에 날짜저장
D1 = sdate;
}
#D1의 값이 0보다 크고
if D1 > 0 then
{
#현재봉날짜가 D1하고 같으면
#현재봉의 분환산값에서 S1을 빼서 TM에 저장
#현재봉 날짜가 D1하고 다르면 (영업일 변경 후 다음날 새벽)
#현재봉의 분환산값에 1440분을 더하고 S1을 빼서 TM에 저장
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
#TM을 6으로 나누고 나머지값 저장
TF1 = TM%ntime1;
#TM을 30으로 나누고 나머지값 저장
TF2 = TM%ntime2;
#6분봉 시작하는 첫봉
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;
#과거 6분구간 최고/최저값을 배열변수의 다음 공간으로 이동
For cnt = 1 to 49
{
H1[cnt] = H1[cnt-1][1];
L1[cnt] = L1[cnt-1][1];
}
}
#현재봉의 고가가 6분구간 최고가보다 크면 구간최고가를 현재봉의 고가로 변경
if H1[0] > 0 and H > H1[0] Then
H1[0] = H;
#현재봉의 저가가 6분구간 최저가보다 작으면 구간최저가를 현재봉의 저가로 변경
if L1[0] > 0 and L < L1[0] Then
L1[0] = L;
#ntime1구간 n개의 최고가/최저가 계산
#초기값
HH = 0;
LL = 0;
if H1[n] > 0 and L1[n] > 0 Then
{
#1~N까지 루프
For cnt = 1 to N
{
#HH가 0이거나 HH에 0보다 큰값이 저장되어 있고 H1[cnt]가 HH보다 크면
#HH를 H1[cnt]값으로 변경
if HH == 0 or (HH > 0 and H1[cnt] > HH) Then
HH = H1[cnt];
#LL이 0이거나 LL이 0보다 큰값이 저장되어 있고 L1[cnt]가 LL보다 작으면
#LL를 L1[cnt]값으로 변경
if LL == 0 or (LL > 0 and L1[cnt] < LL) Then
LL = L1[cnt];
}
}
#30분봉 시작하는 첫봉
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;
#과거 30분구간 최고/최저값을 배열변수의 다음 공간으로 이동
For cnt = 1 to 49
{
H2[cnt] = H2[cnt-1][1];
L2[cnt] = L2[cnt-1][1];
}
}
#현재봉의 고가가 6분구간 최고가보다 크면 구간최고가를 현재봉의 고가로 변경
if H2[0] > 0 and H > H2[0] Then
H2[0] = H;
#현재봉의 저가가 6분구간 최저가보다 작으면 구간최저가를 현재봉의 저가로 변경
if L2[0] > 0 and L < L2[0] Then
L2[0] = L;
#지정한 시간사이이고
if Tcond == true Then
{
#현재 무포지션이거나 매도포지션이고 HH와 h2의 n봉전 값이 0이상이면(사용할값의 계산이 모두된 상태)
#HH와 H2[n]중 큰값을 셋팅하고 다음봉에서 해당값보다 1틱이싱 높은 시세가 발생하면 매수
if MarketPosition <= 0 and HH > 0 and H2[n] > 0 Then
Buy("b",AtStop,max(HH,H2[n])+PriceScale*1);
#현재 무포지션이거나 매수포지션이고 LL, L2의 n봉전 값이 0이상이면(사용할값의 계산이 모두된 상태)
#LL와 L2[n]중 작은값을 셋팅하고 다음봉에서 해당값보다 1틱이싱 낮은 시세가 발생하면 매도
if MarketPosition >= 0 and L1[n] > 0 and L2[n] > 0 Then
Sell("s",AtStop,min(LL,L2[n])-PriceScale*1);
}
}
#익절
SetStopProfittarget(PriceScale*익절틱수,PointStop);
#손절
SetStopLoss(PriceScale*손절틱수,PointStop);
#Endtime에 당일청산
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);
Array : H1[50](0),L1[50](0),H2[50](0),L2[50](0);
var : Tcond(false);
#지정한 종료시간 이후의 첫봉일때 Tcond는 False
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
#지정한 시작시간 이후의 첫봉일때 Tcond는 true
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에 시간을 분으로 환산한 값을 저장
S1 = TimeToMinutes(stime);
#D1에 날짜저장
D1 = sdate;
}
#D1의 값이 0보다 크고
if D1 > 0 then
{
#현재봉날짜가 D1하고 같으면
#현재봉의 분환산값에서 S1을 빼서 TM에 저장
#현재봉 날짜가 D1하고 다르면 (영업일 변경 후 다음날 새벽)
#현재봉의 분환산값에 1440분을 더하고 S1을 빼서 TM에 저장
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
#TM을 6으로 나누고 나머지값 저장
TF1 = TM%ntime1;
#TM을 30으로 나누고 나머지값 저장
TF2 = TM%ntime2;
#6분봉 시작하는 첫봉
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;
#과거 6분구간 최고/최저값을 배열변수의 다음 공간으로 이동
For cnt = 1 to 49
{
H1[cnt] = H1[cnt-1][1];
L1[cnt] = L1[cnt-1][1];
}
}
#현재봉의 고가가 6분구간 최고가보다 크면 구간최고가를 현재봉의 고가로 변경
if H1[0] > 0 and H > H1[0] Then
H1[0] = H;
#현재봉의 저가가 6분구간 최저가보다 작으면 구간최저가를 현재봉의 저가로 변경
if L1[0] > 0 and L < L1[0] Then
L1[0] = L;
#ntime1구간 n개의 최고가/최저가 계산
#초기값
HH = 0;
LL = 0;
if H1[n] > 0 and L1[n] > 0 Then
{
#1~N까지 루프
For cnt = 1 to N
{
#HH가 0이거나 HH에 0보다 큰값이 저장되어 있고 H1[cnt]가 HH보다 크면
#HH를 H1[cnt]값으로 변경
if HH == 0 or (HH > 0 and H1[cnt] > HH) Then
HH = H1[cnt];
#LL이 0이거나 LL이 0보다 큰값이 저장되어 있고 L1[cnt]가 LL보다 작으면
#LL를 L1[cnt]값으로 변경
if LL == 0 or (LL > 0 and L1[cnt] < LL) Then
LL = L1[cnt];
}
}
#30분봉 시작하는 첫봉
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;
#과거 30분구간 최고/최저값을 배열변수의 다음 공간으로 이동
For cnt = 1 to 49
{
H2[cnt] = H2[cnt-1][1];
L2[cnt] = L2[cnt-1][1];
}
}
#현재봉의 고가가 6분구간 최고가보다 크면 구간최고가를 현재봉의 고가로 변경
if H2[0] > 0 and H > H2[0] Then
H2[0] = H;
#현재봉의 저가가 6분구간 최저가보다 작으면 구간최저가를 현재봉의 저가로 변경
if L2[0] > 0 and L < L2[0] Then
L2[0] = L;
#지정한 시간사이이고
if Tcond == true Then
{
#현재 무포지션이거나 매도포지션이고 HH와 h2의 n봉전 값이 0이상이면(사용할값의 계산이 모두된 상태)
#종가가 HH와 H2[n] 중 큰갑보다 크면 매수
if MarketPosition <= 0 and HH > 0 and H2[n] > 0 and C > max(HH,H2[n]) Then
Buy("b");
#현재 무포지션이거나 매수포지션이고 LL, L2의 n봉전 값이 0이상이면(사용할값의 계산이 모두된 상태)
#종가가 LL와 L2[n] 중 작은갑보다 작으면 매도
if MarketPosition >= 0 and LL > 0 and L2[n] > 0 and C < min(LL,L2[n]) Then
Sell("s");
}
}
#익절
SetStopProfittarget(PriceScale*익절틱수,PointStop);
#손절
SetStopLoss(PriceScale*손절틱수,PointStop);
#Endtime에 당일청산
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);
}
}
즐거운 하루되세요
> jesten77 님이 쓴 글입니다.
> 제목 : 문의드립니다
> 수고많으십니다.
아래 내용을 수식으로 만들어 주셨는데요..
실제에는 다르게 나타나서요.
1. 신호나올시 즉시 매수 매도하는 것도 가격이 차이가 많이 납니다.
2. 그리고 종가에 매수 매도하는 것하고 즉시 매수 매도하는 것이
거래 횟수가 5-6배 이상 차이가 나는 것도 이상한 거 같습니다.
두 경우에 신호가 나타난 차트 사진 올려 드립니다.
6분과 30분에 같은 방향 신호가 동시에 나올때 즉시 매수 매도 하는 것과
6분의 종가에 매수매도 하는 2가지 수식을 주셨습니다.
수동으로 복귀해보는 것과 차이가 많이 납니다.
확인 한번 부탁드립니다.
요청했던 부분 다시 남깁니다.
감사합니다.
6분봉과 30분봉, 매수 매도 신호가 나오도록 해주세요.
1. 현재 캔들이 10번째 이전 캔들의 고가를 돌파할때 매수 신호, 저가를 깰때 매도 신호가 나오도록 해주세요. 종가가 아닌 돌파나 깰때 바로 나오도록 해주세요.
2. 현재 캔들이 10번째 이전 캔들의 고가를 돌파하거나 저가를 깨는 일이 같이 일어날 때는 일어나는 그 시각에 해당되는 매수, 매도 신호가 나오도록 해주세요.
3. 10번째 이전 캔들의 고가 위에서 현재 캔들이 앞 캔들의 고가를 높이는 경우, 매수 신호가 나오도록 해주세요.
4. 10번째 이전 캔들의 저가 아래에서 현재 캔들이 앞 캔들의 저가를 깨는 경우 매도 신호가 나오도록 해주세요.
* 위 사항에 대해 6분봉과 30분봉이 같은 방향으로 신호가 있을 때만 그 방향으로 매수, 매도 진입하도록 해주세요.
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);
Array : H1[50](0),L1[50](0),H2[50](0),L2[50](0);
var : Tcond(false);
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;
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];
}
}
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 H1[n] > 0 and H2[n] > 0 and H < min(H1[n],H2[n])+PriceScale*1 Then
Buy("b",AtStop,max(H1[n],H2[n]+PriceScale*1));
if MarketPosition >= 0 and L1[n] > 0 and L2[n] > 0 and L > max(L1[n],L2[n])-PriceScale*1 Then
Sell("s",AtStop,min(L1[n],L2[n])-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);
Array : H1[50](0),L1[50](0),H2[50](0),L2[50](0);
var : Tcond(false);
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;
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];
}
}
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 H1[n] > 0 and H2[n] > 0 and C > H1[n] and C > H2[n] and C > O Then
Buy();
if L1[n] > 0 and L2[n] > 0 and C < L1[n] and C < L2[n] and C < O Then
Sell();
}
}
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);
}
}