예스스탁
예스스탁 답변
2020-01-29 17:28:05
안녕하세요
예스스탁입니다.
input : ntime(60),Length(22),ATRPeriod(22),Mult(3);
var : S1(0),D1(0),TM(0),TF(0),cnt(0),C1(0);
var : sumTR(0),ATRV(0),Hv(0),Lv(0);
var : short_stop(0),long_stop(0),longvs(0),longvs1(0),shortvs(0),shortvs1(0);
var : longswitch(0),shortswitch(0),direction(0),pcup(0),pcdn(0);
Array : TH[100](0),TL[100](0),HH[100](0),LL[100](0),CC[100](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[0] = H;
LL[0] = L;
for cnt = 1 to 99
{
TH[cnt] = TH[cnt-1][1];
TL[cnt] = TL[cnt-1][1];
HH[cnt] = HH[cnt-1][1];
LL[cnt] = LL[cnt-1][1];
CC[cnt] = CC[cnt-1][1];
}
shortvs1 = shortvs[1];
longvs1 = longvs[1];
}
if H > HH[0] Then
HH[0] = H;
if L < LL[0] Then
LL[0] = L;
CC[0] = c;
TH[0] = max(CC[1],HH[0]);
TL[0] = Min(CC[1],LL[0]);
if TH[ATRPeriod-1] > 0 and TL[ATRPeriod-1] > 0 and
HH[Length-1] > 0 and LL[Length-1] > 0 then
{
sumTR = 0;
for cnt = 0 to ATRPeriod-1
{
sumTR = sumTR + (TH[cnt]-TL[cnt]);
}
ATRV = sumTR/ATRPeriod;
Hv = HH[0];
Lv = LL[0];
for cnt = 0 to Length-1
{
if HH[cnt] > Hv Then
Hv = HH[cnt];
if LL[cnt] < Lv Then
Lv = LL[cnt];
}
short_stop = Lv+Mult*atrv;
long_stop = Hv-Mult*atrv;
shortvs = iff(shortvs1 > 0,short_stop,iff(CC[0] > shortvs1, short_stop ,min(short_stop,shortvs1)));
longvs = iff(longvs1 > 0,long_stop,iff(CC[0] < longvs1, long_stop, max(long_stop,longvs1)));
longswitch = iff(CC[0]>=shortvs1 and CC[1]<shortvs1 , 1 , 0);
shortswitch = iff(CC[0]<=longvs1 and CC[1]>longvs1 , 1 , 0);
if direction <= 0 and longswitch == 1 Then
direction = 1;
if direction >= 0 and shortswitch == 1 Then
direction = -1;
if direction > 0 then
pcup = longvs;
if direction < 0 Then
pcdn = shortvs;
if pcup > 0 Then
plot1(pcup);
if pcdn > 0 Then
plot2(pcdn);
}
}
즐거운 하루되세요
> 로즈버드 님이 쓴 글입니다.
> 제목 : 예스트레이더 수식으로 변환 문의드립니다.
> multi timeframe 버전이 아닌 수식으로 알고 있습니다.
1분봉, 5분봉, 30분봉 차트에서 사용할 수 있도록 변환 문의드립니다.
항상 부탁하는 입장이라 감사하고 죄송합니다.
감사합니다.
study("XYZT", overlay=true)
//input variables
Length=input(title="Look Back Period", type=integer, defval=22)
ATRPeriod=input(title="ATR Period", type=integer, defval=22)
Mult=input(title="ATR Multiplier", type=integer, defval=3)
//calculate stop value
short_stop = lowest(Length)+Mult*atr(ATRPeriod)
long_stop = highest(Length)-Mult*atr(ATRPeriod)
shortvs=na(shortvs[1]) ? short_stop : iff(close>shortvs[1], short_stop , min(short_stop,shortvs[1]))
longvs=na(longvs[1]) ? long_stop : iff(close<longvs[1], long_stop, max(long_stop,longvs[1]))
longswitch=iff (close>=shortvs[1] and close[1]<shortvs[1] , 1 , 0)
shortswitch=iff (close<=longvs[1] and close[1]>longvs[1] , 1 , 0)
direction= iff(na(direction[1]), 0,
iff (direction[1]<=0 and longswitch, 1,
iff (direction[1]>=0 and shortswitch, -1, direction[1])))
pcup=direction>0?longvs : na
pcdn=direction<0?shortvs : na
plot(pcup, color=aqua, style=circles, linewidth=2)
plot(pcup, color=aqua, style=linebr, linewidth=2)
plot(pcdn, color=fuchsia, style=circles, linewidth=2)
plot(pcdn, color=fuchsia, style=linebr, linewidth=2)