첨부 이미지
그림1
그림2
수정해주신 수식으로 데모해본 결과 문의 사항이 있어 남김니다.
데모 차트와 거래내역 표시해서 같이 올려 드립니다.
# 먼저 즉시 진입 수식 부분입니다.
1. 22:36 분, 22:51분, 24:00분 은 조건이 맞지 않는데 진입하였습니다.
3번 모두 이전 캔들의 최고가를 돌파하지 않았는데도 매수 진입한 내용입니다.
그리고 현재 거래시간 전에 매수 매도 진입이 되어 익절, 손절이 안된 경우, 거래시간이 종료되면 종료시간에 자동 청산하는데요. 종료시간 이후에 익절 손절 청산 조건대로 청산 가능한 수식이 있으면 부탁드립니다.
아래 수식에서 수정할 부분이 있는지 확인 부탁드립니다.
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];
}
}
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 H2[n] > 0 Then
Buy("b3",AtStop,max(HH,H2[n])+PriceScale*1);
if MarketPosition >= 0 and LL > 0 and L2[n] > 0 Then
Sell("s3",AtStop,min(LL,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);
}
}
답변 1
예스스탁
예스스탁 답변
2021-10-29 15:24:10
안녕하세요
예스스탁입니다.
신호를 살펴보았지만 이상이 없습니다.
예를 들어 22시 36분봉에서 보면 HH는 15582.00이고 H2[n]은 15576.25이니다.
22시36분봉의 시가가 15588.75로 2개의 값보다 크므로 시가에 매수신호가 발생한것 입니다.
다만 랭귀지는 값을 셋팅하고 다음봉 미완성시에 셋팅된 값과 현재가를 비교해 즉시 신호가 발생하게 됩니다.
기본차트에서 다른주기의 봉이 완성되는 시점에 값이 셋팅이 되면 다음주기 첫봉에서 신호가 발생하게 됩니다.
수식에서 즉시 진입은 atstop,atlimit이라는 신호타입으로만 가능합니다.
Buy나 exitshort함수에 사용되면 봉완성시에 값을 셋팅하고
다음봉시세가 셋팅된 값이상의 시세가 발생하면 즉시 발생
sell이나 exitlong함수에 사용되면 봉완성시에 값을 셋팅하고
다음봉시세가 셋팅된 값이하의 시세가 발생하면 즉시 발생하는 구조입니다.
아마 이런 신호체계때문에 신호가 발생한 자리기준으로 보시면
다른주기 최고/최저값과 다를 실수 있습니다.
신호체계가 값은 전봉기준으로 셋팅하고 셋팅된 값과 현재가와 비교하는 구조입니다.
즐거운 하루되세요
> jesten77 님이 쓴 글입니다.
> 제목 : 문의드립니다
> 수정해주신 수식으로 데모해본 결과 문의 사항이 있어 남김니다.
데모 차트와 거래내역 표시해서 같이 올려 드립니다.
# 먼저 즉시 진입 수식 부분입니다.
1. 22:36 분, 22:51분, 24:00분 은 조건이 맞지 않는데 진입하였습니다.
3번 모두 이전 캔들의 최고가를 돌파하지 않았는데도 매수 진입한 내용입니다.
그리고 현재 거래시간 전에 매수 매도 진입이 되어 익절, 손절이 안된 경우, 거래시간이 종료되면 종료시간에 자동 청산하는데요. 종료시간 이후에 익절 손절 청산 조건대로 청산 가능한 수식이 있으면 부탁드립니다.
아래 수식에서 수정할 부분이 있는지 확인 부탁드립니다.
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];
}
}
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 H2[n] > 0 Then
Buy("b3",AtStop,max(HH,H2[n])+PriceScale*1);
if MarketPosition >= 0 and LL > 0 and L2[n] > 0 Then
Sell("s3",AtStop,min(LL,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);
}
}