수고하십니다
a. 3분봉 20 이동평균
b. 30분봉 20 이동평균
c 60분봉 20 이동평균 값에서
a,b,c 모두 이동평균 이상이면 매수 한개라도 아니면 ExitLong
a,b,c 모두 이동평균 이하이면 매도 한개라도 아니면 ExitShort으로하는
수식 부탁드립니다.
감사합니다.
답변 1
예스스탁
예스스탁 답변
2024-06-17 16:03:19
안녕하세요
예스스탁입니다.
3분봉에 적용하시면 됩니다.
3분봉에서 30분,60분이평을 계산하므로
차트에 최대한 많은봉 조회하고 적용하시면 됩니다.
전략실행차트는 최대 1만봉 조회가 됩니다.
input : P(20);
input : ntime1(30),P1(20);
input : ntime2(60),P2(20);
var : S1(0),D1(0),TM(0),TF1(0),TF2(0),cnt(0),mav(0);
var : sum1(0),mav1(0);
var : sum2(0),mav2(0);
Array : C1[100](0),C2[100](0);
mav = ma(C,P);
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
{
for cnt = 99 downto 1
{
C1[cnt] = C1[cnt-1];
}
}
C1[0] = C;
if C1[P1-1] > 0 then
{
sum1 = 0;
for cnt = 0 to P1-1
{
sum1 = sum1+C1[cnt];
}
mav1 = sum1/P1;
}
TF2 = TM%ntime1;
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
{
for cnt = 99 downto 1
{
C2[cnt] = C2[cnt-1];
}
}
C2[0] = C;
if C2[P1-1] > 0 then
{
sum2 = 0;
for cnt = 0 to P2-1
{
sum2 = sum2+C2[cnt];
}
mav2 = sum2/P2;
}
Condition1 = mav1 > 0 and mav2 > 0 and C > max(mav,mav1,mav2);
Condition2 = mav1 > 0 and mav2 > 0 and C < min(mav,mav1,mav2);
if MarketPosition <= 0 and Condition1 == true Then
Buy();
if MarketPosition == 1 and Condition1 == False Then
ExitLong();
if MarketPosition >= 0 and Condition2 == true Then
Sell();
if MarketPosition == -1 and Condition2 == False Then
ExitShort();
}
즐거운 하루되세요
> 네온0609 님이 쓴 글입니다.
> 제목 : 수식 부탁드립니다
>
수고하십니다
a. 3분봉 20 이동평균
b. 30분봉 20 이동평균
c 60분봉 20 이동평균 값에서
a,b,c 모두 이동평균 이상이면 매수 한개라도 아니면 ExitLong
a,b,c 모두 이동평균 이하이면 매도 한개라도 아니면 ExitShort으로하는
수식 부탁드립니다.
감사합니다.