예스스탁
예스스탁 답변
2024-07-05 14:44:11
안녕하세요
예스스탁입니다.
input : starttime(90500),endtime(150000),XTime(151500);
var : Tcond(false,Data2);
if Data2((sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime)) then
{
Tcond = true;
}
if Data2((sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime)) then
{
Tcond = false;
}
// 타주기 1분챠트 5분 주기 표시
input : ntime(5),factor(3), AtrPeriod(10);
var : S1(0,Data2),D1(0,Data2),TM(0,Data2),TF(0,Data2),HH(0,Data2),LL(0,Data2),C1(0,Data2);
var : src(0,Data2), AtrV(0,Data2),ATRv1(0,Data2),upperBand(0,Data2),lowerBand(0,Data2), prevLowerBand(0,Data2), prevUpperBand(0,Data2);
var : prevSuperTrend(0,Data2), superTrend(0,Data2), direction(0,Data2),alpha(0,Data2),source(0,Data2);
if Bdate != Bdate[1] Then
{
S1 = data2(TimeToMinutes(stime));
D1 = data2(sdate);
}
if D1 > 0 then
{
if data2(sdate == D1) Then
TM = data2(TimeToMinutes(stime)-S1);
Else
TM = data2(TimeToMinutes(stime)+1440-S1);
TF = TM%ntime;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and ntime > 1 and TM >= TM[1]+ntime) or
(Bdate == Bdate[1] and ntime == 1 and TM > TM[1]) Then
{
HH = data2(H);
LL = data2(L);
C1 = data2(C[1]);
ATRV1 = ATRV[1];
prevSuperTrend = superTrend[1];
prevLowerBand = lowerBand[1];
prevUpperBand = upperBand[1];
}
if data2(H) > HH Then
HH = data2(H);
if data2(L) < LL Then
LL = data2(L);
src = (HH+LL)/2;
if C1 > 0 Then
{
alpha = 1 / AtrPeriod ;
source = max(HH - LL, abs(HH - C1), abs(LL - C1));
ATrV = alpha * source + (1 - alpha) * ATrV1;
upperBand = src + factor * AtrV;
lowerBand = src - factor * AtrV;
if lowerBand > prevLowerBand or C1 < prevLowerBand Then
lowerBand = lowerBand;
Else
lowerBand = prevLowerBand;
if upperBand < prevUpperBand or C1 > prevUpperBand Then
upperBand = upperBand;
Else
upperBand = prevUpperBand;
if prevSuperTrend == prevUpperBand Then
{
if data2(C) > upperBand Then
direction = -1;
Else
direction = 1;
}
Else
{
if data2(C) < lowerBand Then
direction = 1;
Else
direction = -1;
}
if direction == -1 Then
superTrend = lowerBand;
Else
superTrend = upperBand;
}
}
// data2 의 챠트 신호 발생시 data1에서 매수진입. 매수청산.
if Tcond == true then
{
if data2(crossup(C,superTrend)) then
buy();
if data2(crossdown(C,superTrend)) then
exitlong();
}
SetStopEndofday(XTime);
즐거운 하루되세요
> 뎅이요 님이 쓴 글입니다.
> 제목 : 수식 작성 부탁드립니다
> data2 의 챠트 신호 발생시 (data2 챠트상 Crossup(c , superTrend) 신호 발생시)
data1에서 매수진입.
data2 Crossdown(c , superTrend) 신호 발생시)
data1에서 매수청산 되도록 수식 작성 부탁드립니다.
data1(개별종목), data2(종합지수) 모두 1분 챠트 사용합니다
타주기는 1분챠트에서 5분 챠트 주기의 data2 - Crossup(c , superTrend) data1 - 매수진입,
Crossdown(c , superTrend) data1 - 매수 청산 되도록 원합니다.
매매 시간은
매수 진입 가능 시간 - 오전 9시 5분에 매매시작 15시(오후 3시) 까지 매수 진입 가능,
매수청산 가능 시간 - 오전9시 5분부터 15시 15분까지 매수청산 가능.
15시 이전에 매수 진입한 포지션이 매수 청산, Crossdown(c , superTrend) 15시 15분 까지
신호발생 되지 않으면 15시 15분에 매수청산 즉 당일 청산이 이루어 지도록 수식 원합니다.
input : starttime(90500),endtime(150000),XTime(151500);
var : Tcond(false);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
}
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
if Tcond == true then
{
// 타주기 1분챠트 5분 주기 표시
input : ntime(5),factor(3), AtrPeriod(10);
var : S1(0),D1(0),TM(0),TF(0),HH(0),LL(0),C1(0);
var : src(0), AtrV(0),ATRv1(0),upperBand(0),lowerBand(0), prevLowerBand(0), prevUpperBand(0);
var : prevSuperTrend(0), superTrend(0), direction(0),alpha(0),source(0);
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;
TF = TM%ntime;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and ntime > 1 and TM >= TM[1]+ntime) or
(Bdate == Bdate[1] and ntime == 1 and TM > TM[1]) Then
{
HH = H;
LL = L;
C1 = C[1];
ATRV1 = ATRV[1];
prevSuperTrend = superTrend[1];
prevLowerBand = lowerBand[1];
prevUpperBand = upperBand[1];
}
if H > HH Then
HH = H;
if L < LL Then
LL = L;
src = (HH+LL)/2;
if C1 > 0 Then
{
alpha = 1 / AtrPeriod ;
source = max(HH - LL, abs(HH - C1), abs(LL - C1));
ATrV = alpha * source + (1 - alpha) * ATrV1;
upperBand = src + factor * AtrV;
lowerBand = src - factor * AtrV;
if lowerBand > prevLowerBand or C1 < prevLowerBand Then
lowerBand = lowerBand;
Else
lowerBand = prevLowerBand;
if upperBand < prevUpperBand or C1 > prevUpperBand Then
upperBand = upperBand;
Else
upperBand = prevUpperBand;
if prevSuperTrend == prevUpperBand Then
{
if C > upperBand Then
direction = -1;
Else
direction = 1;
}
Else
{
if C < lowerBand Then
direction = 1;
Else
direction = -1;
}
if direction == -1 Then
superTrend = lowerBand;
Else
superTrend = upperBand;
}
}
// data2 의 챠트 신호 발생시 data1에서 매수진입. 매수청산.
if data2(crossup(C,superTrend)) then
buy();
if data2(crossdown(C,superTrend)) then
exitlong();
}
SetStopEndofday(XTime);