예스스탁
예스스탁 답변
2025-05-09 15:01:01
안녕하세요
예스스탁입니다.
input : starttime(91000),endtime(150000),XTime(151500);
var : Tcond(false,Data1);
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;
}
Inputs: Length(9), StdDev(2), Bars(2);
Variables: BBTop(0,Data1),BBBot(0,Data1);
BBTop = data1(BollBandup(Length, StdDev));
BBBot = data1(BollBanddown(Length, StdDev));
input : 타주기분(5),long(60),sig(9),P(9);
var : S1(0,Data2),D1(0,Data2),TM(0,Data2),TF(0,Data2),cnt(0,Data2),ii(0,Data2),ep(0,Data2);
var : hsum(0),lsum(0),hma(0),lma(0),hi(0),lo(0),hi1(0),lo1(0,Data2);
var : Ema1(0,Data2),Ema2(0,Data2),Ema11(0,Data2),Ema21(0,Data2),mi(0,Data2),sum(0,Data2),sb(0,Data2),sh(0,Data2),mdc(0,Data2);
Array : HH[100](0,Data2),LL[100](0,Data2),CC[100](0,Data2),src[100](0,Data2),md[100](Nan,Data2);
ep = 2/(long+1);
if data2(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%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
ii = ii+1;
For cnt = 99 DownTo 1
{
hh[cnt] = hh[cnt-1];
ll[cnt] = ll[cnt-1];
src[cnt] = src[cnt-1];
md[cnt] = md[cnt-1];
}
hh[0] = data2(h);
ll[0] = data2(l);
hi1 = hi[1];
lo1 = lo[1];
Ema11 = Ema1[1];
Ema21 = Ema2[1];
}
cc[0] = data2(c);
if hh[0] > 0 and data2(h) > hh[0] Then
hh[0] = data2(h);
if ll[0] > 0 and data2(l) < ll[0] Then
ll[0] = data2(l);
src[0] = (hh[0]+ll[0]+cc[0])/3;
if src[long-1] > 0 Then
{
if src[long] == 0 Then
{
hsum = 0;
lsum = 0;
For cnt = 0 to long-1
{
hsum = hsum + hh[cnt];
lsum = lsum + ll[cnt];
}
hi = (hsum/long)/long;
lo = (lsum/long)/long;
}
Else
{
hi = (hi1*(long-1)+hh[0])/long;
lo = (lo1*(long-1)+ll[0])/long;
}
}
if ii <= 1 Then
{
ema1 = src[0];
ema2 = ema1;
}
Else
{
ema1 = src[0] * EP + Ema11 * (1-EP);
ema2 = ema1 * EP + Ema21 * (1-EP);
}
mi = ema1+(ema1-ema2);
md[0] = iff((mi>hi), (mi-hi) , iff((mi<lo) , (mi - lo) , 0));
if md[sig-1] > 0 Then
{
sum = 0;
For cnt = 0 to sig-1
{
sum = sum + md[cnt];
}
sb = sum/sig;
sh = md[0]-sb;
}
}
input : ntime(5),factor(3), AtrPeriod(10);
var : zS1(0,Data2),zD1(0,Data2),zTM(0,Data2),zTF(0,Data2),zHH(0,Data2),zLL(0,Data2),zC1(0,Data2);
var : zsrc(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 data2(Bdate != Bdate[1]) Then
{
zS1 = data2(TimeToMinutes(stime));
zD1 = data2(sdate);
}
if zD1 > 0 then
{
if data2(sdate) == zD1 Then
zTM = data2(TimeToMinutes(stime))-zS1;
Else
zTM = data2(TimeToMinutes(stime))+1440-zS1;
zTF = zTM%ntime;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime > 1 and zTF < zTF[1]) or
(Bdate == Bdate[1] and ntime > 1 and zTM >= zTM[1]+ntime) or
(Bdate == Bdate[1] and ntime == 1 and zTM > zTM[1]) Then
{
zHH = data2(H);
zLL = data2(L);
zC1 = data2(C[1]);
ATRV1 = ATRV[1];
prevSuperTrend = superTrend[1];
prevLowerBand = lowerBand[1];
prevUpperBand = upperBand[1];
}
if data2(H) > zHH Then
zHH = data2(H);
if data2(L) < zLL Then
zLL = data2(L);
zsrc = (zHH+zLL)/2;
if zC1 > 0 Then
{
alpha = 1 / AtrPeriod ;
source = max(zHH - zLL, abs(zHH - zC1), abs(zLL - zC1));
ATrV = alpha * source + (1 - alpha) * ATrV1;
upperBand = zsrc + factor * AtrV;
lowerBand = zsrc - factor * AtrV;
if lowerBand > prevLowerBand or zC1 < prevLowerBand Then
lowerBand = lowerBand;
Else
lowerBand = prevLowerBand;
if upperBand < prevUpperBand or zC1 > 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;
}
}
if Tcond == true then
{
If sb < MD[0] and superTrend < data2(C) and data1(CountIF(Close < BBBot, Bars) == Bars) Then
Buy("B", AtStop, BBBot);
If data1(CountIF(Close > BBTop, Bars) == Bars) Then
Exitlong("Ex", AtStop, BBTop);
}
SetStopEndofday(151500);
즐거운 하루되세요
> 뎅이요 님이 쓴 글입니다.
> 제목 : 수식 부탁드립니다
> 아래 수식을 하나의 수식으로 작성 부탁드립니다.
매매시간내에 data1. 기준에 따라 매매 되며 data2의 3, 4 번의 조건 충족시 매수진입되도록 원합니다.
예시) 매수진입 형식
If (data2의 sb < MD[0] and superTrend < C ) and CountIF(Close < BBBot, Bars) == Bars Then
Buy("B", AtStop, BBBot);
1. 매매시간설정.
9시 10분에 매매시작 15시 까지 매수 진입 허용됨.
15시 이전에 진입한 포지션은 15시 15분까지 Exitlong 신호 발생시 청산됨.
15시 15분까지 Exitlong 신호 발생하지않으면 15시 15분에 당일청산 됨.
input : starttime(91000),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
{
2. data1.신호에 매매
Inputs: Length(9), StdDev(2), Bars(2);
Variables: BBTop(0),BBBot(0);
BBTop = BollBandup(Length, StdDev);
BBBot = BollBanddown(Length, StdDev);
If CountIF(Close < BBBot, Bars) == Bars Then
Buy("B", AtStop, BBBot);
If CountIF(Close > BBTop, Bars) == Bars Then
Exitlong("Ex", AtStop, BBTop);
3. 아래 지표 data2 의 sb < MD[0] 일 때 매수진입 됨.
input : 타주기분(5),long(60),sig(9),P(9);
var : S1(0),D1(0),TM(0),TF(0),cnt(0),ii(0),ep(0);
var : hsum(0),lsum(0),hma(0),lma(0),hi(0),lo(0),hi1(0),lo1(0);
var : Ema1(0),Ema2(0),Ema11(0),Ema21(0),mi(0),sum(0),sb(0),sh(0),mdc(0);
Array : HH[100](0),LL[100](0),CC[100](0),src[100](0),md[100](Nan);
ep = 2/(long+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;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
ii = ii+1;
For cnt = 99 DownTo 1
{
hh[cnt] = hh[cnt-1];
ll[cnt] = ll[cnt-1];
src[cnt] = src[cnt-1];
md[cnt] = md[cnt-1];
}
hh[0] = h;
ll[0] = l;
hi1 = hi[1];
lo1 = lo[1];
Ema11 = Ema1[1];
Ema21 = Ema2[1];
}
cc[0] = c;
if hh[0] > 0 and h > hh[0] Then
hh[0] = h;
if ll[0] > 0 and l < ll[0] Then
ll[0] = l;
src[0] = (hh[0]+ll[0]+cc[0])/3;
if src[long-1] > 0 Then
{
if src[long] == 0 Then
{
hsum = 0;
lsum = 0;
For cnt = 0 to long-1
{
hsum = hsum + hh[cnt];
lsum = lsum + ll[cnt];
}
hi = (hsum/long)/long;
lo = (lsum/long)/long;
}
Else
{
hi = (hi1*(long-1)+hh[0])/long;
lo = (lo1*(long-1)+ll[0])/long;
}
}
if ii <= 1 Then
{
ema1 = src[0];
ema2 = ema1;
}
Else
{
ema1 = src[0] * EP + Ema11 * (1-EP);
ema2 = ema1 * EP + Ema21 * (1-EP);
}
mi = ema1+(ema1-ema2);
md[0] = iff((mi>hi), (mi-hi) , iff((mi<lo) , (mi - lo) , 0));
if md[sig-1] > 0 Then
{
sum = 0;
For cnt = 0 to sig-1
{
sum = sum + md[cnt];
}
sb = sum/sig;
sh = md[0]-sb;
}
4.아래 지표가 data2 의 superTrend < C 일 때 매수진입 됨.
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;