답변완료
수고하십니다
수고하십니다
변곡점에 세로선 처리하다 수식이 이상하게 됐습니다
수정 부탁드립니다
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
552
글번호 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
611
글번호 184862
지표
답변완료
수고하십니다
항상 노고에 감사 합니다
변환부탁드립니다 주말 잘보내세요
indicator("AI-Powered Breakout with Advanced Features", shorttitle="Breakout AI", overlay=true, max_bars_back=500, max_lines_count=400)
// Inputs
length = input.int(20, minval=1, title="Lookback Length")
multiplier = input.float(1.5, title="Multiplier for Adaptive MA")
src = input(close, title="Source")
prd = input.int(defval=5, title="Period", minval=2)
bo_len = input.int(defval=200, title="Max Breakout Length", minval=30, maxval=300)
cwidthu = input.float(defval=3., title="Threshold Rate %", minval=1., maxval=10) / 100
mintest = input.int(defval=2, title="Minimum Number of Tests", minval=1)
bocolorup = input.color(defval=color.blue, title="Breakout Colors", inline="bocol")
bocolordown = input.color(defval=color.red, title="", inline="bocol")
lstyle = input.string(defval="line.style_solid", title="Line Style", options=["line.style_solid", "line.style_dashed", "line.style_dotted"])
// Convert line style from string to line style type
getLineStyle(style) =>
switch style
"line.style_solid" => line.style_solid
"line.style_dashed" => line.style_dashed
"line.style_dotted" => line.style_dotted
lineStyle = getLineStyle(lstyle)
// Calculate Highest High and Lowest Low
highestHigh = ta.highest(high, length)
lowestLow = ta.lowest(low, length)
// Calculate Breakout Levels
breakoutLevel = highestHigh
breakdownLevel = lowestLow
// AI Component: Adaptive Moving Average
fastMA = ta.ema(src, length)
slowMA = ta.ema(fastMA, length)
adaptiveMA = fastMA + multiplier * (fastMA - slowMA)
// Breakout Signals
breakoutSignal = ta.crossover(close, breakoutLevel) and close > adaptiveMA
breakdownSignal = ta.crossunder(close, breakdownLevel) and close < adaptiveMA
// Plot Breakout Levels using line.new
var line breakoutLine = na
var line breakdownLine = na
if na(breakoutLine)
breakoutLine := line.new(x1=bar_index[1], y1=breakoutLevel[1], x2=bar_index, y2=breakoutLevel, color=color.green, style=line.style_dotted)
else
line.set_xy1(breakoutLine, bar_index[1], breakoutLevel[1])
line.set_xy2(breakoutLine, bar_index, breakoutLevel)
if na(breakdownLine)
breakdownLine := line.new(x1=bar_index[1], y1=breakdownLevel[1], x2=bar_index, y2=breakdownLevel, color=color.red, style=line.style_dotted)
else
line.set_xy1(breakdownLine, bar_index[1], breakdownLevel[1])
line.set_xy2(breakdownLine, bar_index, breakdownLevel)
// Additional Breakout Finder Logic
lll = math.max(math.min(bar_index, 300), 1)
float h_ = ta.highest(lll)
float l_ = ta.lowest(lll)
float chwidth = (h_ - l_) * cwidthu
// Check if Pivot High/Low
ph = ta.pivothigh(prd, prd)
pl = ta.pivotlow(prd, prd)
// Keep Pivot Points and their locations in arrays
var phval = array.new_float(0)
var phloc = array.new_int(0)
var plval = array.new_float(0)
var plloc = array.new_int(0)
// Keep PH/PL levels and locations
if not na(ph)
array.unshift(phval, ph)
array.unshift(phloc, bar_index - prd)
if array.size(phval) > 1
for x = array.size(phloc) - 1 to 1
if bar_index - array.get(phloc, x) > bo_len
array.pop(phloc)
array.pop(phval)
if not na(pl)
array.unshift(plval, pl)
array.unshift(plloc, bar_index - prd)
if array.size(plval) > 1
for x = array.size(plloc) - 1 to 1
if bar_index - array.get(plloc, x) > bo_len
array.pop(plloc)
array.pop(plval)
// Check bullish cup
float bomax = na
int bostart = bar_index
num = 0
hgst = ta.highest(prd)[1]
if array.size(phval) >= mintest and close > open and close > hgst
bomax := array.get(phval, 0)
xx = 0
for x = 0 to array.size(phval) - 1
if array.get(phval, x) >= close
break
xx := x
bomax := math.max(bomax, array.get(phval, x))
if xx >= mintest and open <= bomax
for x = 0 to xx
if array.get(phval, x) <= bomax and array.get(phval, x) >= bomax - chwidth
num += 1
bostart := array.get(phloc, x)
if num < mintest or hgst >= bomax
bomax := na
if not na(bomax) and num >= mintest
line.new(x1=bar_index, y1=bomax, x2=bostart, y2=bomax, color=bocolorup, style=lineStyle)
line.new(x1=bar_index, y1=bomax - chwidth, x2=bostart, y2=bomax - chwidth, color=bocolorup, style=lineStyle)
line.new(x1=bostart, y1=bomax - chwidth, x2=bostart, y2=bomax, color=bocolorup, style=lineStyle)
line.new(x1=bar_index, y1=bomax - chwidth, x2=bar_index, y2=bomax, color=bocolorup, style=lineStyle)
plotshape(not na(bomax) and num >= mintest, location=location.belowbar, style=shape.triangleup, color=bocolorup, size=size.small)
alertcondition(not na(bomax) and num >= mintest, title="Breakout", message="Breakout")
// Check bearish cup
float bomin = na
bostart := bar_index
num1 = 0
lwst = ta.lowest(prd)[1]
if array.size(plval) >= mintest and close < open and close < lwst
bomin := array.get(plval, 0)
xx = 0
for x = 0 to array.size(plval) - 1
if array.get(plval, x) <= close
break
xx := x
bomin := math.min(bomin, array.get(plval, x))
if xx >= mintest and open >= bomin
for x = 0 to xx
if array.get(plval, x) >= bomin and array.get(plval, x) <= bomin + chwidth
num1 += 1
bostart := array.get(plloc, x)
if num1 < mintest or lwst <= bomin
bomin := na
if not na(bomin) and num1 >= mintest
line.new(x1=bar_index, y1=bomin, x2=bostart, y2=bomin, color=bocolordown, style=lineStyle)
line.new(x1=bar_index, y1=bomin + chwidth, x2=bostart, y2=bomin + chwidth, color=bocolordown, style=lineStyle)
line.new(x1=bostart, y1=bomin + chwidth, x2=bostart, y2=bomin, color=bocolordown, style=lineStyle)
line.new(x1=bar_index, y1=bomin + chwidth, x2=bar_index, y2=bomin, color=bocolordown, style=lineStyle)
plotshape(not na(bomin) and num1 >= mintest, location=location.abovebar, style=shape.triangledown, color=bocolordown, size=size.small)
alertcondition(not na(bomin) and num1 >= mintest, title="Breakdown", message="Breakdown")
alertcondition((not na(bomax) and num >= mintest) or (not na(bomin) and num1 >= mintest), title="Breakout or Breakdown", message="Breakout or Breakdown")
2024-10-31
962
글번호 184861
지표