예스스탁
예스스탁 답변
2020-12-01 12:37:31
안녕하세요
예스스탁입니다.
특정시간에 매수나 매도를 하기 위해서는 차트가 분봉이하의 주기여야 합니다.
또한 지정한 날짜이후의 해당월의 첫 영업일에 신호가 발생하기 위해서는
해당월의 첫날의 데이타 까지 필요하고 차트에 매수신호가 없으면 청산이 발생하지 못합니다.
전략실행차트는 최대 1만개 봉까지 제공되므로
1만개 봉안에 매수와 매도날짜가 모두 포함될 수 있는 분봉 주기로 적용해 주셔야 합니다.
1
input : 매수월(12),매수일(15),매수시간(120000);
input : 매도월(6),매도일(14),매도시간(120000);
var : MM(0),DD(0),entry(0),exit(0);
MM = Floor(FracPortion(bdate/10000)*100);
DD = sDate%100;
if Bdate > Bdate[1]+30 Then
{
entry = 0;
if MM == 매수월 Then
entry = 1;
}
if entry == 1 and Bdate != Bdate[1] and DD >= 매수일 Then
entry = 2;
if entry == 2 and
((sDate != sDate[1] and sTime >= 매수시간) or
(sDate == sDate[1] and sTime >= 매수시간 and sTime[1] < 매수시간)) Then
{
entry = 3;
Buy("b");
}
if Bdate > Bdate[1]+30 Then
{
exit = 0;
if MM == 매도월 Then
exit = 1;
}
if exit == 1 and Bdate != Bdate[1] and DD >= 매도일 Then
exit = 2;
if exit == 2 and
((sDate != sDate[1] and sTime >= 매도시간) or
(sDate == sDate[1] and sTime >= 매도시간 and sTime[1] < 매도시간)) Then
{
exit = 3;
ExitLong("bx");
}
2
매수/매도요일은 1이 월요일, 2는 화요일, 3은 수요일, 4는 목요일, 5는 금요일입니다.
input : 매수월(12),매수요일(2),n번째요일매수(2),매수시간(120000);
input : 매도월(6),매도요일(1),n번째요일매도(3),매도시간(120000);
var : MM(0),DD(0),entry(0),exit(0);
Var : Year(0),Month(0);
var : cnt(0),count(0),ndate(0),ED(0),XD(0);
if Bdate > Bdate[1]+30 then
{
Year = Floor(bDate / 10000)*10000;
month = Floor(FracPortion(bdate/10000)*100);
entry = 0;
if Month == 매수월 Then
{
entry = 1;
ndate = year+month*100+1;
count = 0;
for cnt = 0 to 30
{
if dayofweek(ndate+cnt) == 매수요일 Then
{
count = count+1;
if count == n번째요일매수 Then
{
ED = ndate+cnt;
}
}
}
}
Exit = 0;
if Month == 매도월 Then
{
Exit = 1;
ndate = year+month*100+1;
count = 0;
for cnt = 0 to 30
{
if dayofweek(ndate+cnt) == 매도요일 Then
{
count = count+1;
if count == n번째요일매도 Then
{
XD = ndate+cnt;
}
}
}
}
}
if entry == 1 and Bdate != Bdate[1] and Bdate >= ED Then
entry = 2;
if entry == 2 and
((sDate != sDate[1] and sTime >= 매수시간) or
(sDate == sDate[1] and sTime >= 매수시간 and sTime[1] < 매수시간)) Then
{
entry = 3;
Buy("b");
}
if exit == 1 and Bdate != Bdate[1] and Bdate >= XD Then
exit = 2;
if exit == 2 and
((sDate != sDate[1] and sTime >= 매도시간) or
(sDate == sDate[1] and sTime >= 매도시간 and sTime[1] < 매도시간)) Then
{
exit = 3;
ExitLong("bx");
}
즐거운 하루되세요
> lch05 님이 쓴 글입니다.
> 제목 : 매년 특정월/특정일 매수
> <1> 매년 12월 15일 오후 12시에 매수해서 다음 해 6월 14일 오후 12시에 매도하는 수식 부탁드립니다.
<2> 매년 12월 두번째주 화요일 오후 12시에 매수해서 다음 해 6월 세번째주 월요일 오후 12시에 매도하는 수식 부탁드립니다.
두 경우 각각 만약 해당일자가 휴일이면 바로 다음 business day에 실행되게 부탁드립니다.