예스스탁
예스스탁 답변
2020-09-28 18:26:15
안녕하세요
예스스탁입니다.
1
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDO;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
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;
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
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = TM%ntime2;
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
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > 0 and MACDO2 > 0 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < 0 and MACDO2 < 0 Then
Sell();
}
2
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0),PreMACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0),PreMACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDO;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
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;
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
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
PreMACDO1 = MACDO1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = TM%ntime2;
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
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
PreMACDO2 = MACDO2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > PreMACDO1 and MACDO2 > PreMACDO2 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < PreMACDO1 and MACDO2 < PreMACDO2 Then
Sell();
}
3
input : n(20);
var : sum(0),mav(0),cnt(0);
sum = 0;
For cnt = 1 to n
{
sum = sum + (DayHigh(cnt)-DayLow(cnt));
}
mav = sum/n;
if MarketPosition == 0 and NextBarSdate == sDate Then
Buy("b",AtStop,DayOpen+mav);
if MarketPosition == 1 Then
{
ExitLong("bl",AtStop,EntryPrice-mav*0.25);
if NextBarSdate != sDate Then
exitlong("bx",AtMarket);
}
즐거운 하루되세요
> 고르면상한가 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> 안녕하세요.
여러가지 질문을 드리게 될 것 같아서 최대한 간략하게 정리해서 요청드립니다.
1. Case 1
(매수진입조건)
60분봉, 30분봉, 15분봉 MACD 오실레이터 값이 +0(변수) 이상일 때 매수 진입
단 진입 타이밍을 결정하는 분봉은 15분봉 기준의 오실레이터 값이 +0(변수) 판단하게 됨.
(매도 진입조건)
매수 조건 반대기준과 -0(변수)이하일 때 매도 진입.
MACD 오실레이터 값은 기본값 적용
2. Case 2
(매수진입조건)
30분, 60분봉 MACD Oscillator 값이 상승중이고
15분봉 MACD 값이 시그널값을 골든크로스 발생시 매수진입
(매도진입조건)
매수 진입조건 반대로.
MACD 오실레이터 값은 기본값 적용
3. Case 3
일봉기준 Range계산(20일평균-단 해당 부분은 변수로 설정 필요) : 전일(변수)고가 - 전일(변수)저가
매수 : 당일 장중 가격 > 당일 시가 + 전일 Range (돌파시 매수)
매도 : 다음날 시가 시장가 청산
손절기준 : 진입가 대비 전일 Range 1/4 이하 하락시 손절
고르면상한가
2020-09-29 02:10:18
안녕하세요
전달주신 전략식에 대한 설명을 좀 달아주시면 도움이 많이 될 것 같습니다.
일단 시그널 자체가 발생되지 않아 var의 항목들과 임의변수들에 대한 설명
그리고 Bdate쪽에 대한 의미들을 설명을 달아주시면 분석하는데에 도움이 될 것 같습니다.
그리고
1,2번 문의항목기준에서 추가적으로 분봉 기준의 값을 틱단위 기준으로 변형하려면 어떻게 해야하는지 알면 좋을 것 같습니다.
번거로우시겠지만 부탁드립니다.
그 외 혹시 여러개의 분봉차트를 띄워야지만 전략이 정상적으로 되는것인지도
문의드립니다.
초보라 질문이 많았습니다
감사합니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 부탁드립니다.
>
안녕하세요
예스스탁입니다.
1
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDO;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
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;
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
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = TM%ntime2;
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
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > 0 and MACDO2 > 0 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < 0 and MACDO2 < 0 Then
Sell();
}
2
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0),PreMACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0),PreMACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDO;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
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;
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
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
PreMACDO1 = MACDO1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = TM%ntime2;
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
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
PreMACDO2 = MACDO2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > PreMACDO1 and MACDO2 > PreMACDO2 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < PreMACDO1 and MACDO2 < PreMACDO2 Then
Sell();
}
3
input : n(20);
var : sum(0),mav(0),cnt(0);
sum = 0;
For cnt = 1 to n
{
sum = sum + (DayHigh(cnt)-DayLow(cnt));
}
mav = sum/n;
if MarketPosition == 0 and NextBarSdate == sDate Then
Buy("b",AtStop,DayOpen+mav);
if MarketPosition == 1 Then
{
ExitLong("bl",AtStop,EntryPrice-mav*0.25);
if NextBarSdate != sDate Then
exitlong("bx",AtMarket);
}
즐거운 하루되세요
> 고르면상한가 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> 안녕하세요.
여러가지 질문을 드리게 될 것 같아서 최대한 간략하게 정리해서 요청드립니다.
1. Case 1
(매수진입조건)
60분봉, 30분봉, 15분봉 MACD 오실레이터 값이 +0(변수) 이상일 때 매수 진입
단 진입 타이밍을 결정하는 분봉은 15분봉 기준의 오실레이터 값이 +0(변수) 판단하게 됨.
(매도 진입조건)
매수 조건 반대기준과 -0(변수)이하일 때 매도 진입.
MACD 오실레이터 값은 기본값 적용
2. Case 2
(매수진입조건)
30분, 60분봉 MACD Oscillator 값이 상승중이고
15분봉 MACD 값이 시그널값을 골든크로스 발생시 매수진입
(매도진입조건)
매수 진입조건 반대로.
MACD 오실레이터 값은 기본값 적용
3. Case 3
일봉기준 Range계산(20일평균-단 해당 부분은 변수로 설정 필요) : 전일(변수)고가 - 전일(변수)저가
매수 : 당일 장중 가격 > 당일 시가 + 전일 Range (돌파시 매수)
매도 : 다음날 시가 시장가 청산
손절기준 : 진입가 대비 전일 Range 1/4 이하 하락시 손절
예스스탁
예스스탁 답변
2020-09-29 09:34:57
안녕하세요
예스스탁입니다.
기본차트의 MACD오실레이터 계산이 문제가 있어 수정했습니다.
타주기 계산로직은 동일한 내용이므로 ntim1에 대한 부분만 주석을 남겨드립니다.
다른주기의 지표계산은 기본차트의 주기에서 배수로 높은 주기만 가능합니다.
기본차트가 분봉인 상태에서 틱봉의 값은 계산이 불가능하고
기본차트가 틱봉인 상태에서 분봉의 값은 구현이 불가능합니다.
틱봉에서 기존 답변수식을 이용하시면 근사값으로 계산을 하게 됩니다.
틱봉에서 다른주기의 틱봉계산하는 로직은 1-2, 1-2로 아래에 추가해 드립니다.
기본차트기준 n1,n2배 높은 주기입니다.
로직상 차트의 시간주기 구분이 당일봉을 n개씩 모아 계산하는것만 다릅니다.
1
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
#기본차트 MACD
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDS;
#지수이평 계산을 위한 계수
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
#영업일변경
if Bdate != Bdate[1] Then
{
#영업일변경시 밤0시 이후 경과된 시간(분)
S1 = TimeToMinutes(stime);
#달력상 날짜
D1 = sdate;
}
#D1에 값이 저장되고(차트상 날짜변경이 1회이상 발생한 후)
if D1 > 0 then
{
#국내와 해외선물 모두에서 영엽일 변경이후 경과한 분을 계산하기 위함.
#현재봉의 달력상 날짜가 D1하고 같으면
#현재봉의 0시이후 경과된 시간(분)에서 S1을 차감해서
#현재봉의 달력상 날짜가 D1하고 다르면(새벽시간)
#현재봉 시간에 24시에 해당하는 분을 더하고 D1을 차감
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
#TM을 ntime1로 나누고 나오지 값을 취함
TF1 = TM%ntime1;
#각봉의 TM을 기준으로 지정한 시간 주기로 자르기 위한 내용
#영엽일이 변경된 봉이거나
#영업일은 전봉과 같지만 ntime1이상이고 TF1이 한봉전 대비 작아지거나
#영업일은 전봉과 같지만 ntime1이상이고 TM이 한봉전 대비 ntime1이상 크거나(거래가 없어 시간이 많이 경과해 다음봉이 생길경우를 대비)
#영업일은 전봉과 같지만 ntime1이 1이면 TM이 한봉전 대비 증가
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
{
#타주기의 봉갯수
idx1 = idx1 + 1;
#전봉의 단기지수이평값
Prexma1 = xma1[1];
#전봉의 장기지수이평값
Prexma2 = xma2[1];
#전봉의 MACD시그널값
PreMACDS1 = MACDS1[1];
}
#타주기봉이 1개 이하일 때믄
if idx1 <= 1 then
{
#이평들은 해당봉의 종가
xma1 = C;
xma2 = C;
#MACD는 단기지수이평-장기지수이평
MACDV1 = xma1-xma2;
#MACD시그널은 MACD값
MACDS1 = MACDV1;
#MACD오실레이터는 MACD에서 MACD시그널 차감
MACDO1 = MACDV1-MACDS1;
}
else#타주기봉이 2개이상이 만들어진 이후에는
{
#현재봉종가에 EP1의 가중치를 주고 전봉의 지수이평에는 1-EP1가중치를 주어 단기지수이평계산
xma1 = C * EP1 + Prexma1 * (1-EP1);
#현재봉종가에 EP2의 가중치를 주고 전봉의 지수이평에는 1-EP2가중치를 주어 장기지수이평계산
xma2 = C * EP2 + Prexma2 * (1-EP2);
#MACD는 단기지수이평-장기지수이평
MACDV1 = xma1-xma2;
#MACD시그널은 MACD에 EP3의 가중치를 주고 전봉의 MACD시그널에 1-EP3가중치를 주어 시그널값곗한
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
#MACD오실레이터는 MACD에서 MACD시그널 차감
MACDO1 = MACDV1-MACDS1;
}
TF2 = TM%ntime2;
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
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > 0 and MACDO2 > 0 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < 0 and MACDO2 < 0 Then
Sell();
}
2
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0),PreMACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0),PreMACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDS;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
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;
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
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
PreMACDO1 = MACDO1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = TM%ntime2;
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
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
PreMACDO2 = MACDO2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > PreMACDO1 and MACDO2 > PreMACDO2 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < PreMACDO1 and MACDO2 < PreMACDO2 Then
Sell();
}
1-2
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDS;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
if Bdate != Bdate[1] Then
{
S1 = 0;
D1 = sdate;
}
Else
S1 = S1+1;
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF1 = S1%ntime1;
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF1 < TF1[1]) Then
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = S1%ntime2;
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF2 < TF2[1]) Then
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > 0 and MACDO2 > 0 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < 0 and MACDO2 < 0 Then
Sell();
}
2-2
input : ntime1(3),ntime2(5),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0),PreMACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0),PreMACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDS;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
if Bdate != Bdate[1] Then
{
S1 = 0;
D1 = sdate;
}
Else
S1 = S1+1;
if D1 > 0 then
{
TF1 = S1%ntime1;
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF1 < TF1[1]) Then
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
PreMACDO1 = MACDO1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = S1%ntime2;
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF2 < TF2[1]) Then
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
PreMACDO2 = MACDO2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > PreMACDO1 and MACDO2 > PreMACDO2 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < PreMACDO1 and MACDO2 < PreMACDO2 Then
Sell();
}
> 고르면상한가 님이 쓴 글입니다.
> 제목 : Re : Re : 부탁드립니다.
> 안녕하세요
전달주신 전략식에 대한 설명을 좀 달아주시면 도움이 많이 될 것 같습니다.
일단 시그널 자체가 발생되지 않아 var의 항목들과 임의변수들에 대한 설명
그리고 Bdate쪽에 대한 의미들을 설명을 달아주시면 분석하는데에 도움이 될 것 같습니다.
그리고
1,2번 문의항목기준에서 추가적으로 분봉 기준의 값을 틱단위 기준으로 변형하려면 어떻게 해야하는지 알면 좋을 것 같습니다.
번거로우시겠지만 부탁드립니다.
그 외 혹시 여러개의 분봉차트를 띄워야지만 전략이 정상적으로 되는것인지도
문의드립니다.
초보라 질문이 많았습니다
감사합니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 부탁드립니다.
>
안녕하세요
예스스탁입니다.
1
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDO;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
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;
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
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = TM%ntime2;
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
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > 0 and MACDO2 > 0 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < 0 and MACDO2 < 0 Then
Sell();
}
2
input : ntime1(30),ntime2(60),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : TF1(0),xma1(0),xma2(0),idx1(0),Prexma1(0),Prexma2(0),MACDV1(0),MACDS1(0),PreMACDS1(0),MACDO1(0),PreMACDO1(0);
var : TF2(0),ema1(0),ema2(0),idx2(0),Preema1(0),Preema2(0),MACDV2(0),MACDS2(0),PreMACDS2(0),MACDO2(0),PreMACDO2(0);
var : MACDV(0),MACDS(0),MACDO(0);
MACDV = MACD(short,long);
MACDS = Ema(MACDV,sig);
MACDO = MACDV-MACDO;
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
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;
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
{
idx1 = idx1 + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS1 = MACDS1[1];
PreMACDO1 = MACDO1[1];
}
if idx1 <= 1 then {
xma1 = C;
xma2 = C;
MACDV1 = xma1-xma2;
MACDS1 = MACDV1;
MACDO1 = MACDV1-MACDS1;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV1 = xma1-xma2;
MACDS1 = MACDV1 * EP3 + PreMACDS1 * (1-EP3);
MACDO1 = MACDV1-MACDS1;
}
TF2 = TM%ntime2;
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
{
idx2 = idx2 + 1;
Preema1 = ema1[1];
Preema2 = ema2[1];
PreMACDS2 = MACDS2[1];
PreMACDO2 = MACDO2[1];
}
if idx2 <= 1 then {
ema1 = C;
ema2 = C;
MACDV2 = ema1-ema2;
MACDS2 = MACDV2;
MACDO2 = MACDV2-MACDS2;
}
else{
ema1 = C * EP1 + Preema1 * (1-EP1);
ema2 = C * EP2 + Preema2 * (1-EP2);
MACDV2 = ema1-ema2;
MACDS2 = MACDV2 * EP3 + PreMACDS2 * (1-EP3);
MACDO2 = MACDV2-MACDS2;
}
if CrossUp(MACDO,0) and MACDO1 > PreMACDO1 and MACDO2 > PreMACDO2 Then
Buy();
if CrossDown(MACDO,0) and MACDO1 < PreMACDO1 and MACDO2 < PreMACDO2 Then
Sell();
}
3
input : n(20);
var : sum(0),mav(0),cnt(0);
sum = 0;
For cnt = 1 to n
{
sum = sum + (DayHigh(cnt)-DayLow(cnt));
}
mav = sum/n;
if MarketPosition == 0 and NextBarSdate == sDate Then
Buy("b",AtStop,DayOpen+mav);
if MarketPosition == 1 Then
{
ExitLong("bl",AtStop,EntryPrice-mav*0.25);
if NextBarSdate != sDate Then
exitlong("bx",AtMarket);
}
즐거운 하루되세요
> 고르면상한가 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> 안녕하세요.
여러가지 질문을 드리게 될 것 같아서 최대한 간략하게 정리해서 요청드립니다.
1. Case 1
(매수진입조건)
60분봉, 30분봉, 15분봉 MACD 오실레이터 값이 +0(변수) 이상일 때 매수 진입
단 진입 타이밍을 결정하는 분봉은 15분봉 기준의 오실레이터 값이 +0(변수) 판단하게 됨.
(매도 진입조건)
매수 조건 반대기준과 -0(변수)이하일 때 매도 진입.
MACD 오실레이터 값은 기본값 적용
2. Case 2
(매수진입조건)
30분, 60분봉 MACD Oscillator 값이 상승중이고
15분봉 MACD 값이 시그널값을 골든크로스 발생시 매수진입
(매도진입조건)
매수 진입조건 반대로.
MACD 오실레이터 값은 기본값 적용
3. Case 3
일봉기준 Range계산(20일평균-단 해당 부분은 변수로 설정 필요) : 전일(변수)고가 - 전일(변수)저가
매수 : 당일 장중 가격 > 당일 시가 + 전일 Range (돌파시 매수)
매도 : 다음날 시가 시장가 청산
손절기준 : 진입가 대비 전일 Range 1/4 이하 하락시 손절