답변완료
부탁드립니다.
★이 봉 바로 위. 아래에 표시 될 수 있도록 수정 부탁드립니다.
input : length(20);
input : len2(10);
input : showsignals(true);
input : highlighting(true);
var : upper(0),lower(0);
lower = lowest(L,length);
upper = highest(H,length);
plot1(upper, "Upper");
plot2(lower, "Lower");
var : up(0),down(0),sup(0),sdown(0);
var : k1(0),k2(0),k3(0),k4(0),i1(-1),i2(-1);
up=highest(high,length);
down=lowest(low,length);
sup=highest(high,len2);
sdown=lowest(low,len2);
if high >= up[1] Then
i1 = 0;
Else
{
if i1 >= 0 Then
i1 = i1+1;
}
if Low <= down[1] Then
i2 = 0;
Else
{
if i2 >= 0 Then
i2 = i2+1;
}
K1=iff(i1 <=i2, down , up);
K2=iff(i1 <= i2,sdown,sup);
K3=iff(close>K1,down,nan);
K4=iff(close<K1,up,nan);
plot3(K1,"Trend Line",red);
plot4(K2,"Exit Line",blue);
var : buySignal(False),sellSignal(False),buyExit(False),sellExit(False);
var : O1(-1),O2(-1),O3(-1),O4(-1);
var : E1(-1),E2(-1),E3(-1),E4(-1);
var : tx1(0),tx2(0),tx3(0),tx4(0);
var : tx5(0),tx6(0),tx7(0),tx8(0);
buySignal=high==upper[1] or CrossUp(high,upper[1]);
sellSignal = low==lower[1] or CrossUp(lower[1],low);
buyExit=low==sdown[1] or CrossUp(sdown[1],low);
sellExit = high==sup[1] or CrossUp(high,sup[1]);
if BuySignal == true Then
var1 = Index;
if sellSignal == true Then
var2 = Index;
if buyExit == true Then
var3 = Index;
if sellExit == true Then
var4 = Index;
O1= IFf(var1 > 0,Index-var1,-1);
O2= IFf(var2 > 0,Index-var2,-1);
O3= IFf(var3 > 0,Index-var3,-1);
O4= IFf(var4 > 0,Index-var4,-1);
if BuySignal[1] == true Then
var5 = Index;
if sellSignal[1] == true Then
var6 = Index;
if buyExit[1] == true Then
var7 = Index;
if sellExit[1] == true Then
var8 = Index;
E1= IFf(var5 > 0,Index-var5,-1);
E2= IFf(var6 > 0,Index-var6,-1);
E3= IFf(var7 > 0,Index-var7,-1);
E4= IFf(var8 > 0,Index-var8,-1);
if buySignal and O3<O1[1] Then
{
tx1 = Text_New(sDate,sTime,down,"★");
Text_SetStyle(tx1,2,0);
Text_SetColor(tx1,Red);
Text_SetSize(tx1,20);
}
if sellSignal and O4<O2[1] Then
{
tx3 = Text_New(sDate,sTime,up,"★");
Text_SetStyle(tx3,2,1);
Text_SetColor(tx3,Green);
Text_SetSize(tx3,20);
}
아래 수식은 박스에 생기는 위아래 숫자를 없애주시고
반대로 교차되는 수식도 넣어서 하늘색 박스가 생기도록 부탁드립니다
var : T(0),dd(0),tt(0),hh(0),ll(0);
var : box(0),tx1(0),tx2(0);
var1 = ma(C,5);
var2 = ma(C,20);
if CrossUp(var1,var2) Then
{
T = 1;
dd = sDate;
tt = sTime;
hh = h;
ll = l;
box = Box_New(dd,tt,hh,NextBarSdate,NextBarStime,ll);
Box_SetColor(box,rgb(255, 184, 102));
Box_SetFill(box,true);
tx1 = Text_New(sDate,sTime,hh,NumToStr(hh,2));
Text_SetStyle(tx1,2,1);
tx2 = Text_New(sDate,sTime,ll,NumToStr(hh,2));
Text_SetStyle(tx2,2,0);
}
if CrossDown(var1,var2) Then
T = -1;
if T == 1 Then
{
if h > hh Then
hh = h;
if l < ll Then
ll = l;
Box_SetBegin(box,dd,tt,hh);
Box_SetEnd(box,NextBarSdate,NextBarStime,ll);
Text_SetString(tx1,NumToStr(hh,2));
Text_SetLocation(tx1,sDate,sTime,hh);
Text_SetString(tx2,NumToStr(ll,2));
Text_SetLocation(tx2,sDate,sTime,ll);
}
2025-06-19
238
글번호 191902
지표
답변완료
수식 부탁드립니다
지표식 부탁 드립니다.
//@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
189
글번호 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
256
글번호 191897
지표