답변완료
수식도움 부탁드립니다.
////////////트레이딩뷰 원 수식
//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);
2022-12-12
1517
글번호 164497
지표
답변완료
잘 부탁드립니다
input : n1(10),n2(21),obLevel1(60),obLevel2(53),osLevel1(-60),osLevel2(-53);
var : ap(0),esa(0),dd(0),ci(0),tci(0),wt1(0),wt2(0);
ap = (h+l+c)/3 ;
esa = ema(ap, n1);
dd = ema(abs(ap - esa), n1);
ci = (ap - esa) / (0.015 * dd);
tci = ema(ci, n2);
wt1 = tci;
wt2 = ma(wt1,4);
plot1(0,"0",GRAY);
plot2(obLevel1,"obLevel1",red);
plot3(osLevel1,"osLevel1",green);
plot4(obLevel2,"obLevel2",red);
plot5(osLevel2,"osLevel2",green);
plot6(wt1,"wt1",green);
plot7(wt2,"wt2",red);
plot8(wt1-wt2,"wt1-wt2",blue);
1, 0선 아래에서 골드나는 매수
2, -50 -60선 아래서 골드발생만 매수
3, wt1 이 wt2 를 골드 하는 매수 매도 시스템응 부탁 드립니다
### 언제나 항상 많은 도움 감사드립니다 ###
### 부족한 설명이 있거나 부족한것이 있다면 검토해서 잘 부탁드립니다###
2022-12-11
1373
글번호 164495
시스템
답변완료
수식 검증 수정부탁드립니다.
트레이딩뷰 지표를 예스지표로 변환하려는데,
어디서 오류가 있는것인지 출력이 되지 않습니다.
점검 수정 부탁드립니다.
////////////////트레이딩뷰 원 지표식 //////////
study(title="UT Bot Alerts", overlay = true)
// Inputs
a = input(1, title = "Key Vaule. 'This changes the sensitivity'")
c = input(10, title = "ATR Period")
h = input(false, title = "Signals from Heikin Ashi Candles")
xATR = atr(c)
nLoss = a * xATR
src = h ? security(heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = false) : close
xATRTrailingStop = 0.0
xATRTrailingStop := iff(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss),
iff(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss),
iff(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss)))
pos = 0
pos := iff(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1,
iff(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0)))
xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue
ema = ema(src,1)
above = crossover(ema, xATRTrailingStop)
below = crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny)
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
alertcondition(buy, "UT Long", "UT Long")
alertcondition(sell, "UT Short", "UT Short")
////////// 제가 변환해본 식 ////////
Input : a(1), length(10),크기(15);
var : truehighv(0),TrueLowv(0),TrueRangev(0),xatr(0),nLoss(0),src(0) ;
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
var : xATRTrailingStop(0),poss(0), emav(0), ab(0), be(0),tx(0) ;
var : dir(0) ;
if index == 0 then
{
xOpen = open;
xClose = (O+H+L+C)/4;
xHigh = MaxList( high, xOpen, xClose);
xLow = MinList( low, xOpen,xClose);
}
else
{
xClose = (O+H+L+C)/4;
xOpen = (xOpen [1] + xClose [1])/2 ;
xHigh = MaxList(High, xOpen, xClose) ;
xLow = MinList(Low, xOpen, xClose) ;
}
////////
If xClose[1] > xHigh then
TrueHighv = xClose[1];
else
TrueHighv = xHigh;
If xClose[1] < xLow then
TrueLowv = xClose[1];
else
TrueLowv = xLow;
TrueRangev = TrueHighv - TrueLowv;
xatr = ma(TrueRangev,length);
nLoss = a * xatr ;
##########
src = xClose ;
xATRTrailingStop = 0.0 ;
xATRTrailingStop = iff(src > xATRTrailingStop[1] and src[1] > xATRTrailingStop[1],
max(xATRTrailingStop[1], src - nLoss),
iff(src < xATRTrailingStop[1] and src[1] < xATRTrailingStop[1],
min(xATRTrailingStop[1],src + nLoss),
iff(src > xATRTrailingStop[1], src - nLoss, src + nLoss)));
poss = 0 ;
poss = iff(src[1] < xATRTrailingStop[1] and src > xATRTrailingStop[1], 1,
iff(src[1] > xATRTrailingStop[1] and src < xATRTrailingStop[1], -1, poss[1])) ;
emav = ema(src,1);
if crossup(emav, xATRTrailingStop) Then ab == true ;
if crossup(xATRTrailingStop, emav) Then be == true ;
////////////
dir = iff(src > xATRTrailingStop and ab == true , 1 ,iff( src < xATRTrailingStop and be == true , -1 , dir));
if dir == 1 and dir[1] == -1
Then
{
tx = Text_New(sDate,sTime,low,"▲");
Text_SetStyle(tx,2,0);
Text_SetSize(tx, 크기);
Text_SetColor(tx,black);
}
if dir == -1 and dir[1] == 1
Then
{
tx = Text_New(sDate,sTime,high,"▼");
Text_SetStyle(tx,2,1);
Text_SetSize(tx, 크기);
Text_SetColor(tx,black);
}
//////////////
2022-12-11
1724
글번호 164494
지표