답변완료
수식 부탁드립니다
지표식 부탁 드립니다.
//@version=5
indicator('Linear Regression Bands', overlay = true, max_lines_count = 3)
// ─────────────────────────────
// USER INPUTS
// ─────────────────────────────
bool bands = input.bool(true, "Plot Linear Regression Bands")
int window = input.int(100, "Length")
float devlen_b = input.float(2.0, "Deviation Linear Regression Bands", step=0.1)
// ─────────────────────────────
// COLOR SETTINGS
// ─────────────────────────────
color col_dn = #f01313
color col_up = color.aqua
color col_mid = color.yellow
color gray = color.gray
// ─────────────────────────────
// LINEAR REGRESSION CALC
// ─────────────────────────────
linear_regression(src, window) =>
sum_x = 0.0
sum_y = 0.0
sum_xy = 0.0
sum_x_sq = 0.0
for i = 0 to window - 1
sum_x += i + 1
sum_y += src[i]
sum_xy += (i + 1) * src[i]
sum_x_sq += math.pow(i + 1, 2)
slope = (window * sum_xy - sum_x * sum_y) / (window * sum_x_sq - math.pow(sum_x, 2))
intercept = (sum_y - slope * sum_x) / window
y1 = intercept + slope * (window - 1)
dev = 0.0
for i = 0 to window - 1
dev += math.pow(src[i] - (slope * (window - i) + intercept), 2)
dev := math.sqrt(dev / window)
[intercept, y1, dev, slope]
// ─────────────────────────────
// PLOT
// ─────────────────────────────
[y2, _, dev, slope] = linear_regression(close, window)
mid = y2 + slope
upper = mid + ta.rma(high - low, window) * devlen_b
lower = mid - ta.rma(high - low, window) * devlen_b
p_u = plot(bands ? upper : na, color = bands ? gray : na, linewidth = 2)
p_l = plot(bands ? lower : na, color = bands ? gray : na, linewidth = 2)
p_m = plot(bands ? mid : na, color = bands ? gray : na)
fill(p_u, p_m, mid, upper, na, bands ? color.new(col_up, 80) : na)
fill(p_m, p_l, lower, mid, bands ? color.new(col_dn, 80) : na, na)
2025-06-19
164
글번호 191899
지표
답변완료
문의드립니다.
아래의 1번 지표수식에 2번의 heikin ashi(이하 ha) 고가 저가 종가를 적용하는 수식으로 변경 가능할까요?
차트에 ha캔들은 나타내지 않고 1번수식의 typicalprice 에서 high low close를
ha캔들 값으로 변경적용해서 차트에 나타내고자 하는 것이 목적입니다.
부탁드립니다. 그리고 감사드립니다. 수고하세요!!!
=========================
1.
//@version=4
study(title="VWAP-VWMA-ATR", shorttitle="Adapted-ATR", overlay=true)
//VWAP
cumulativePeriod = input(30, "Period")
typicalPrice = (high + low + close) / 3
typicalPriceVolume = typicalPrice * volume
cumulativeTypicalPriceVolume = sum(typicalPriceVolume, cumulativePeriod)
cumulativeVolume = sum(volume, cumulativePeriod)
vwapValue = cumulativeTypicalPriceVolume / cumulativeVolume
//VWMA
shortlen = input(10, minval=1)
longlen = input(30, minval=1)
short = ema(volume, shortlen)
long = ema(volume, longlen)
osc = 100 * (short - long) / long
//ATR-Stop
p=input(200,"Period")
m=input(5,"Multiplier")
max=close[1]+atr(p)[1]*m
min=close[1]-atr(p)[1]*m
stop=min
hi=true
hi:=hi[1]?high[1]>=stop[1]?false:true:low[1]<=stop[1]?true:false
stop:=hi?max:min
stop:=hi?hi[1]==false?stop:stop>stop[1]?stop[1]:stop:hi[1]?stop:stop<stop[1]?stop[1]:stop
//VWAP-VWMA-ATR
c1 =(stop+osc+vwapValue)/2
//ATRCOLOR
atrcolor=(c1>close?color.red:color.green)
//Plot
plot(c1, title="Adapted-ATR", linewidth=2, color=atrcolor, transp=0)
//BarColor
barcolor(close>c1 ? color.green : color.red)
===========================
2.
indicator('Heiken Ashi Candles', 'Heiken Ashi', overlay = true)
//Heiken Ashi
isHA = input(true, 'HA Candles')
heikenashi_1 = ticker.heikinashi(syminfo.tickerid)
data = isHA ? heikenashi_1 : syminfo.tickerid
o = request.security(data, timeframe.period, open)
h = request.security(data, timeframe.period, high)
l = request.security(data, timeframe.period, low)
c = request.security(data, timeframe.period, close)
col = c > o ? color.green : color.red
plotcandle(o, h, l, c, 'Heiken Ashi', col, color.black)
2025-06-19
225
글번호 191897
지표