예스스탁
예스스탁 답변
2022-12-12 14:40:18
안녕하세요
예스스탁입니다.
input : 분1(240),P(20);
var : S1(0),D1(0),TM(0),TF1(0),cnt(0),ii(0);
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
var : xClose1(0),xOpen1(0),xHigh1(0),xLow1(0);
var : dd(0),dClose(0),dOpen(0),dHigh(0),dLow(0);
var : dClose1(0),dOpen1(0),EP(0),MTema20(0),PreMTema20(0),MTema20delta(0);
var : LTlong(False),LTshort(False),MTlong(False),MTshort(False);
var : Long(False),short(False);
Array : oo[100](0),hh[100](0),ll[100](0),cc[100](0);
Ep = 2/(P+1);
if Bdate != Bdate[1] Then
{
dd = dd+1;
S1 = TimeToMinutes(stime);
D1 = sdate;
dOpen1 = dOpen[1];
dClose1 = dClose[1];
}
if dd == 1 Then
{
dOpen = dayopen(0);
dClose = (DayOpen(0)+DayHigh(0)+DayLow(0)+DayClose(0))/4;
dHigh = MaxList(DayHigh(0), dOpen, dClose);
dLow = MinList(DayLow(0), dOpen,dClose);
}
else
{
dClose = (oo[0]+hh[0]+ll[0]+cc[0])/4;
dOpen = (dOpen1 + dClose1)/2 ;
dHigh = MaxList(hh[0], dOpen, dClose) ;
dLow = MinList(ll[0], dOpen, dClose) ;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF1 = TM%분1;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 분1 > 1 and TF1 < TF1[1]) or
(Bdate == Bdate[1] and 분1 > 1 and TM >= TM[1]+분1) or
(Bdate == Bdate[1] and 분1 == 1 and TM > TM[1]) Then
{
ii = ii +1;
For cnt = 99 DownTo 1
{
oo[cnt] = oo[cnt-1];
hh[cnt] = hh[cnt-1];
ll[cnt] = ll[cnt-1];
cc[cnt] = cc[cnt-1];
}
oo[0] = o;
hh[0] = h;
ll[0] = l;
Xopen1 = xopen[1];
Xhigh1 = xhigh[1];
Xlow1 = xlow[1];
Xclose1 = xclose[1];
PreMTema20 = MTema20[1];
}
if hh[0] > 0 and h > hh[0] Then
hh[0] = h;
if ll[0] > 0 and l < ll[0] Then
ll[0] = l;
cc[0] = c;
if ii == 1 then
{
xOpen = oo[0];
xClose = (oo[0]+hh[0]+ll[0]+cc[0])/4;
xHigh = MaxList(hh[0], xOpen, xClose);
xLow = MinList(ll[0], xOpen,xClose);
MTema20 = xClose;
}
else
{
xClose = (oo[0]+hh[0]+ll[0]+cc[0])/4;
xOpen = (xOpen1 + xClose1)/2 ;
xHigh = MaxList(hh[0], xOpen, xClose) ;
xLow = MinList(ll[0], xOpen, xClose) ;
MTema20 = xClose * EP + PreMTema20 * (1-EP);
}
MTema20delta = MTema20-PreMTema20;
LTlong = dClose > dOpen;
LTshort = dClose < dOpen;
MTlong = xClose > xOpen and xClose > MTema20 and MTema20delta > 0;
MTshort = xClose < xOpen and xClose < MTema20 and MTema20delta < 0;
Long = MTlong and LTlong;
Short = MTshort and LTshort;
plot1(iff(Long, 1 , IFf( Short , -1 , 0)),"TrendAlert",iff(Long, lime , IFf( Short , red , gray)));
}
즐거운 하루되세요
> 당일선물 님이 쓴 글입니다.
> 제목 : 수식도움 부탁드립니다.
> ////////////트레이딩뷰 원 수식
//Heiken Ashi Candles
data = heikenashi(tickerid)
resLT = input(title="Res LT", type=resolution, defval="D")
resMT = input(title="Res MT", type=resolution, defval="240")
LTo = security(data, resLT, open)
LTc = security(data, resLT, close)
MTo = security(data, resMT, open)
MTc = security(data, resMT, close)
LTlong = LTc > LTo
LTshort = LTc < LTo
MTema20 = ema(MTc,20)
MTema20delta= change(MTema20)
MTlong = MTc > MTo and MTc > MTema20 and MTema20delta > 0
MTshort = MTc < MTo and MTc < MTema20 and MTema20delta < 0
Long = MTlong and LTlong
Short = MTshort and LTshort
plot(Long ? 1 : Short ? -1: 0, title="TrendAlert", color= Long ? lime : Short ? red : gray, style=columns )
############
////////////// 제가 변환 해본 수식
# 변환하는데 잘 몰라서 오류가 있는 듯한데
#점검 부탁드립니다.
////////////////
input : 분1(60),분2(15),period(20);
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
var : xClose1(0),xOpen1(0),xHigh1(0),xLow1(0);
var : xClose2(0),xOpen2(0),xHigh2(0),xLow2(0);
var : xClose21(0),xOpen21(0),xHigh21(0),xLow21(0);
var : S1(0),D1(0),TM(0),TF1(0),TF2(0),cnt(0),ii(0),ii2(0);
var : sum(0), mav(0),mavdelta(0);
var : TrendAlert(0);
Array : oo[100](0),hh[100](0),ll[100](0),cc[100](0);
Array : oo2[100](0),hh2[100](0),ll2[100](0),cc2[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;
///
TF1 = TM%분1;
TF2 = TM%분2;
///15분
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 분1 > 1 and TF1 < TF1[1]) or
(Bdate == Bdate[1] and 분1 > 1 and TM >= TM[1]+분1) or
(Bdate == Bdate[1] and 분1 == 1 and TM > TM[1]) Then
{
ii = ii +1;
For cnt = 99 DownTo 1
{
oo[cnt] = oo[cnt-1];
hh[cnt] = hh[cnt-1];
ll[cnt] = ll[cnt-1];
cc[cnt] = cc[cnt-1];
}
oo[0] = o;
hh[0] = h;
ll[0] = l;
Xopen1 = xopen[1];
Xhigh1 = xhigh[1];
Xlow1 = xlow[1];
Xclose1 = xclose[1];
}
if hh[0] > 0 and h > hh[0] Then
hh[0] = h;
if ll[0] > 0 and l < ll[0] Then
ll[0] = l;
cc[0] = c;
if ii == 1 then
{
xOpen = oo[0];
xClose = (oo[0]+hh[0]+ll[0]+cc[0])/4;
xHigh = MaxList(hh[0], xOpen, xClose);
xLow = MinList(ll[0], xOpen,xClose);
}
else
{
xClose = (oo[0]+hh[0]+ll[0]+cc[0])/4;
xOpen = (xOpen1 + xClose1)/2 ;
xHigh = MaxList(hh[0], xOpen, xClose) ;
xLow = MinList(ll[0], xOpen, xClose) ;
}
#####5분
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 분2 > 1 and TF2 < TF2[1]) or
(Bdate == Bdate[1] and 분2 > 1 and TM >= TM[1]+분2) or
(Bdate == Bdate[1] and 분2 == 1 and TM > TM[1]) Then
{
ii2 = ii2 +1;
For cnt = 99 DownTo 1
{
oo2[cnt] = oo2[cnt-1];
hh2[cnt] = hh2[cnt-1];
ll2[cnt] = ll2[cnt-1];
cc2[cnt] = cc2[cnt-1];
}
oo2[0] = o;
hh2[0] = h;
ll2[0] = l;
Xopen21 = xopen2[1];
Xhigh21 = xhigh2[1];
Xlow21 = xlow2[1];
Xclose21 = xclose2[1];
}
if hh2[0] > 0 and h > hh2[0] Then
hh2[0] = h;
if ll2[0] > 0 and l < ll2[0] Then
ll2[0] = l;
cc2[0] = c;
if ii == 1 then
{
xOpen2 = oo2[0];
xClose2 = (oo2[0]+hh2[0]+ll2[0]+cc2[0])/4;
xHigh2 = MaxList(hh2[0], xOpen2, xClose2);
xLow2 = MinList(ll2[0], xOpen2,xClose2);
}
else
{
xClose2 = (oo2[0]+hh2[0]+ll2[0]+cc2[0])/4;
xOpen2 = (xOpen21 + xClose21)/2 ;
xHigh2 = MaxList(hh2[0], xOpen2, xClose2) ;
xLow2 = MinList(ll2[0], xOpen2, xClose2) ;
}
if CC2[period-1] > 0 then
{
sum = 0;
for cnt = 0 to period-1
{
sum = sum+CC[cnt];
}
mav = sum/period;
mavdelta = mav - mav[1];
}
}
if xclose > xopen
and xclose2 > xopen2
and xclose2 > mav
and mavdelta > 0
Then TrendAlert = 1 ;
if xclose < xopen
and xclose2 < xopen2
and xclose2 < mav
and mavdelta < 0
Then TrendAlert = -1 ;
if trendalert == 1 Then
Plot1(TrendAlert,"TrendAlert",orange);
if trendalert == -1 Then
Plot1(TrendAlert,"TrendAlert",green);