답변완료
수고하십니다
수고하십니다
변곡점에 세로선 처리하다 수식이 이상하게 됐습니다
수정 부탁드립니다
input : pd(22), bbl(20), mult(2.0), lb(50), ph(0.85), pl(1.01);
var : wvf(0),sDev(0),midLine(0), upperBand(0), rangeHigh(0),color(0), OverSold(0),TL1(0), TX1(0), TL2(0), TX2(0) ;
var : wvf_inv(0), sDev2(0),midLine2(0), upperBand2(0), rangeHigh2(0),color2(0), Overbought(0);
wvf = ((highest(close, pd)-low)/(highest(close, pd)))*100;
wvf_inv = ((high-lowest(close, pd))/lowest(close, pd))*100;
sDev = mult * std(wvf, bbl);
midLine = ma(wvf, bbl);
upperBand = midLine + sDev;
rangeHigh = (highest(wvf, lb)) * ph;
sDev2 = mult * std(wvf_inv, bbl);
midLine2 = ma(wvf_inv, bbl);
upperBand2 = midLine2 + sDev2;
rangeHigh2 = (highest(wvf_inv, lb)) * ph;
if wvf >= upperBand or wvf >= rangeHigh Then
OverSold = 1;
Else
OverSold = 0;
color = iff(OverSold == 1, RGB(000,255,000), RGB(128,128,128));
if wvf_inv >= upperBand2 or wvf_inv >= rangeHigh2 Then
Overbought = 1;
Else
Overbought = 0;
if CountIF(OverSold[1] > 0 ,4) == 4 and OverSold == 0 Then
color = RED;
TL1 = TL_New(sDate, sTime, 0, sDate, sTime, 999999999);
TX1 = Text_New(sDate, sTime, Lowest(L,pd),"매수" );
TL_SetColor(TL1, Lime);
TEXT_SetColor(TX1, Lime);
Text_SetStyle(TX1, 0, 0);
color2 = iff(Overbought == 1, RGB(255,102,0), GRAY);
if CountIF(Overbought[1] > 0 ,4) == 4 and Overbought == 0 Then
color2 = BLUE;
TL2 = TL_New(sDate, sTime, 0, sDate, sTime, 999999999);
TX2 = Text_New(sDate, sTime, Lowest(H,pd),"매도" );
TL_SetColor(TL2, Blue);
TEXT_SetColor(TX2, Blue);
Text_SetStyle(TX2, 0, 0);
Plot1(-wvf,"wvf",color);
plot2(wvf_inv,"wvf_inv",color2);
2024-10-31
591
글번호 184863
지표
답변완료
문의 드립니다
안녕하세요
트리뷰 지표전환입니다
1.
length = input(14)
mult = input(2)
//------------------------------------------------------------------------------
upper = 0.,lower = 0.,os = 0,max = 0.,min = 0.
src = close
atr = ta.atr(length)*mult
up = hl2 + atr
dn = hl2 - atr
upper := src[1] < upper[1] ? math.min(up,upper[1]) : up
lower := src[1] > lower[1] ? math.max(dn,lower[1]) : dn
os := src > upper ? 1 : src < lower ? 0 : os[1]
spt = os == 1 ? lower : upper
max := ta.cross(src,spt) ? nz(math.max(max[1],src),src) :
os == 1 ? math.max(src,max[1]) :
math.min(spt,max[1])
min := ta.cross(src,spt) ? nz(math.min(min[1],src),src) :
os == 0 ? math.min(src,min[1]) :
math.max(spt,min[1])
avg = math.avg(max,min)
//------------------------------------------------------------------------------
var area_up_col = color.new(#0cb51a,80)
var area_dn_col = color.new(#ff1100,80)
plot0 = plot(max,'Upper Channel'
,max != max[1] and os == 1 ? na : #0cb51a)
plot1 = plot(avg,'Average'
,#ff5d00)
plot2 = plot(min,'Lower Channel'
,min != min[1] and os == 0 ? na : #ff1100)
fill(plot0,plot1,area_up_col,'Upper Area')
fill(plot1,plot2,area_dn_col,'Lower Area')
2.
// 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")
감사합니다
2024-11-01
660
글번호 184862
지표