답변완료
변환 부탁드립니다.
안녕하세요?
아래 트뷰 지표를 나름 변경해 보았습니다. 예스랭귀지에서 에러는 발생하지 않는데, 화면에 아무것도 안나오네요. 제가 만든 스크립트 무시하더라도 최대한 트뷰와 비슷하게 수정부탁드립니다.
== 변경 ==
Input: left(14), right(14), areaOpt(0);
Input: showTop(True), showBtm(True);
Var: ph(false), pl(false);
Var: ph_top(0), ph_btm(0), ph_vol(0);
Var: pl_top(0), pl_btm(0), pl_vol(0);
Var: i(0);
Var: ph_boxID(0), pl_boxID(0), ph_tlID(0), pl_tlID(0), ph_txtID(0), pl_txtID(0);
ph = swinghigh(1, High, left, right, 0) != -1;
pl = swinglow(1, Low, left, right, 0) != -1;
If ph == True and showTop == True then {
ph_top = High[right];
If areaOpt == 0 then
ph_btm = Max(Close[right], Open[right]);
else
ph_btm = Low[right];
// 거래량 누적(박스범위 내)
ph_vol = 0;
For i = right To left + right - 1 {
If (Low[i] < ph_top and High[i] > ph_btm) then
ph_vol = ph_vol + Volume[i];
}
// 기존 오브젝트 삭제
If ph_boxID != 0 then Box_Delete(ph_boxID);
If ph_tlID != 0 then TL_Delete(ph_tlID);
If ph_txtID != 0 then Text_Delete(ph_txtID);
ph_boxID = Box_New(
sDate[left + right - 1], sTime[left + right - 1], ph_top,
sDate[right], sTime[right], ph_btm
);
Box_SetColor(ph_boxID, rgb(246,79,8));
Box_SetFill(ph_boxID, True, 120, True);
// 수평선(피벗 구간 전체)
ph_tlID = TL_New(sDate[left + right - 1], sTime[left + right - 1], ph_top, sDate[right], sTime[right], ph_top);
TL_SetColor(ph_tlID, rgb(246,79,8));
TL_SetSize(ph_tlID, 2);
// 거래량 라벨(박스 좌상단에 표시)
ph_txtID = Text_New(sDate[left + right - 1], sTime[left + right - 1], ph_top, "V:" + NumToStr(ph_vol, 0));
Text_SetStyle(ph_txtID, 1, rgb(246,79,8));
}
If pl == True and showBtm == True then {
pl_top = Iff(areaOpt == 0, Min(Close[right], Open[right]), High[right]);
pl_btm = Low[right];
pl_vol = 0;
For i = right To left + right - 1 {
If (Low[i] < pl_top and High[i] > pl_btm) then
pl_vol = pl_vol + Volume[i];
}
If pl_boxID != 0 then Box_Delete(pl_boxID);
If pl_tlID != 0 then TL_Delete(pl_tlID);
If pl_txtID != 0 then Text_Delete(pl_txtID);
pl_boxID = Box_New(
sDate[left + right - 1], sTime[left + right - 1], pl_top,
sDate[right], sTime[right], pl_btm
);
Box_SetColor(pl_boxID, rgb(10,139,109));
Box_SetFill(pl_boxID, True, 120, True);
pl_tlID = TL_New(sDate[left + right - 1], sTime[left + right - 1], pl_btm, sDate[right], sTime[right], pl_btm);
TL_SetColor(pl_tlID, rgb(10,139,109));
TL_SetSize(pl_tlID, 2);
pl_txtID = Text_New(sDate[left + right - 1], sTime[left + right - 1], pl_btm, "V:" + NumToStr(pl_vol, 0));
Text_SetStyle(pl_txtID, 1, rgb(10,139,109));
}
== 트뷰 ==
//@version=5
indicator("예시"
, overlay = true
, max_lines_count = 500
, max_labels_count = 500
, max_boxes_count = 500)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
length = input(14, 'Period')
area = input.string('Wick only', 'Swing Range', options = ['Wick only', 'Full Bar'])
//Style
showTop = input(true, '저항', inline = 'top', group = 'Style')
topCss = input(#f64f08, '' , inline = 'top', group = 'Style')
topAreaCss = input(#ff52525c, 'Area', inline = 'top', group = 'Style')
showBtm = input(true, '지지', inline = 'btm', group = 'Style')
btmCss = input(#0a8b6d, '' , inline = 'btm', group = 'Style')
btmAreaCss = input(#00897b53, 'Area', inline = 'btm', group = 'Style')
labelSize = input.string('Tiny', 'Labels Size', options = ['Tiny', 'Small', 'Normal'], group = 'Style')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index
get_counts(condition, top, btm)=>
var count = 0
var vol = 0.
if condition
count := 0
vol := 0.
else
vol += low[length] < top and high[length] > btm ? volume[length] : 0
count += low[length] < top and high[length] > btm ? 1 : 0
[count, vol]
set_label(count, vol, x, y, css, lbl_style)=>
var label lbl = na
var label_size = switch labelSize
'Tiny' => size.tiny
'Small' => size.small
'Normal' => size.normal
target = count
if ta.crossover(target, 0)
lbl := label.new(x, y, str.tostring(vol, format.volume)
, style = lbl_style
, size = label_size
, color = #00000000
, textcolor = css)
if target > 0
label.set_text(lbl, str.tostring(vol, format.volume))
set_level(condition, crossed, value, count, vol, css)=>
var line lvl = na
target = count
if condition
if target[1] < 0[1]
line.delete(lvl[1])
else if not crossed[1]
line.set_x2(lvl, n - length)
lvl := line.new(n - length, value, n, value
, color = na)
if not crossed[1]
line.set_x2(lvl, n+3)
if crossed and not crossed[1]
line.set_x2(lvl, n)
line.set_style(lvl, line.style_dashed)
if target > 0
line.set_color(lvl, css)
set_zone(condition, x, top, btm, count, vol, css)=>
var box bx = na
target = count
if ta.crossover(target, 0)
bx := box.new(x, top, x + count, btm
, border_color = na
, bgcolor = css)
if target > 0
box.set_right(bx, x + count)
//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
//Pivot high
var float ph_top = na
var float ph_btm = na
var bool ph_crossed = na
var ph_x1 = 0
var box ph_bx = box.new(na,na,na,na
, bgcolor = color.new(topAreaCss, 80)
, border_color = na)
//Pivot low
var float pl_top = na
var float pl_btm = na
var bool pl_crossed = na
var pl_x1 = 0
var box pl_bx = box.new(na,na,na,na
, bgcolor = color.new(btmAreaCss, 80)
, border_color = na)
//-----------------------------------------------------------------------------}
//Display pivot high levels/blocks
//-----------------------------------------------------------------------------{
ph = ta.pivothigh(length, length)
//Get ph counts
[ph_count, ph_vol] = get_counts(ph, ph_top, ph_btm)
//Set ph area and level
if ph and showTop
ph_top := high[length]
ph_btm := switch area
'Wick only' => math.max(close[length], open[length])
'Full Bar' => low[length]
ph_x1 := n - length
ph_crossed := false
box.set_lefttop(ph_bx, ph_x1, ph_top)
box.set_rightbottom(ph_bx, ph_x1, ph_btm)
else
ph_crossed := close > ph_top ? true : ph_crossed
if ph_crossed
box.set_right(ph_bx, ph_x1)
else
box.set_right(ph_bx, n+3)
if showTop
//Set ph zone
set_zone(ph, ph_x1, ph_top, ph_btm, ph_count, ph_vol, topAreaCss)
//Set ph level
set_level(ph, ph_crossed, ph_top, ph_count, ph_vol, topCss)
//Set ph label
set_label(ph_count, ph_vol, ph_x1, ph_top, topCss, label.style_label_down)
//-----------------------------------------------------------------------------}
//Display pivot low levels/blocks
//-----------------------------------------------------------------------------{
pl = ta.pivotlow(length, length)
//Get pl counts
[pl_count, pl_vol] = get_counts(pl, pl_top, pl_btm)
//Set pl area and level
if pl and showBtm
pl_top := switch area
'Wick only' => math.min(close[length], open[length])
'Full Bar' => high[length]
pl_btm := low[length]
pl_x1 := n - length
pl_crossed := false
box.set_lefttop(pl_bx, pl_x1, pl_top)
box.set_rightbottom(pl_bx, pl_x1, pl_btm)
else
pl_crossed := close < pl_btm ? true : pl_crossed
if pl_crossed
box.set_right(pl_bx, pl_x1)
else
box.set_right(pl_bx, n+3)
if showBtm
//Set pl zone
set_zone(pl, pl_x1, pl_top, pl_btm, pl_count, pl_vol, btmAreaCss)
//Set pl level
set_level(pl, pl_crossed, pl_btm, pl_count, pl_vol, btmCss)
//Set pl labels
set_label(pl_count, pl_vol, pl_x1, pl_btm, btmCss, label.style_label_up)
//-----------------------------------------------------------------------------}
2025-06-09
281
글번호 191537
지표
답변완료
수식변환 부탁드립니다.늘 감사합니다
1번**
//@version=6
indicator("Reversal BB", overlay = true)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input(50)
float factor = input.float(1.0, "Factor", step = 0.1)
// Color
color col_up = input(color.lime, "", inline = "col")
color col_dn = input(color.rgb(221, 26, 26), "", inline = "col")
color col_ul = input(color.aqua, "", inline = "col")
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
trend(length)=>
var direction = 0
var count_up = 0.
var count_dn = 0.
float volatility = ta.sma(high-low, 70) * factor
float upper = ta.highest(ta.sma(close, 25) + volatility, int(length/2))
float lower = ta.lowest(ta.sma(close, length) - volatility, int(length/2))
bool sig_up = ta.crossover(hlc3, upper) and barstate.isconfirmed
bool sig_dn = ta.crossunder(hlc3, lower) and barstate.isconfirmed
switch
sig_up => direction := 1
sig_dn => direction := -1
upper := direction == 1 ? float(na) : upper
lower := direction == -1 ? float(na) : lower
// Trends Duration
if direction == 1
count_up += 0.5
count_dn := 0
if direction == -1
count_dn += 0.5
count_up := 0
count_up := count_up > 70 ? 70 : count_up
count_dn := count_dn > 70 ? 70 : count_dn
[upper, lower, direction, count_up, count_dn]
[upper, lower, direction, count_up, count_dn] = trend(length)
float upper_band = lower + ta.atr(100)*5
float lower_band = upper - ta.atr(100)*5
color upper_col = color.new(col_dn, int(count_dn))
color lower_col = color.new(col_up, int(count_up))
color upper_band_col = color.new(col_ul, 70 - int(count_up))
color lower_band_col = color.new(col_ul, 70 - int(count_dn))
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
plot(upper_band, "Upper Wave", style = plot.style_linebr, color = bar_index % 2 == 0 ? na : upper_band_col, linewidth = 1)
plot(lower_band, "Lower Wave", style = plot.style_linebr, color = bar_index % 2 == 0 ? na : lower_band_col, linewidth = 1)
plot(upper, "Upper Band", style = plot.style_linebr, color = upper_col, linewidth = 2)
plot(lower, "Lower Band", style = plot.style_linebr, color = lower_col, linewidth = 2)
plot(upper, "Upper Band Shadow", style = plot.style_linebr, color = color.new(col_dn, int(count_dn*2)), linewidth = 6)
plot(lower, "Lower Band Shadow", style = plot.style_linebr, color = color.new(col_up, int(count_up*2)), linewidth = 6)
plotshape(direction != direction[1] and direction == 1 ? lower : na, "Trend Up", shape.circle, location.absolute, size = size.tiny, color = col_up)
plotshape(direction != direction[1] and direction == 1 ? lower : na, "Trend Up", shape.circle, location.absolute, size = size.small, color = color.new(col_up, 70))
plotshape(direction != direction[1] and direction == -1 ? upper : na, "Trend Down", shape.circle, location.absolute, size = size.tiny, color = col_dn)
plotshape(direction != direction[1] and direction == -1 ? upper : na, "Trend Down", shape.circle, location.absolute, size = size.small, color = color.new(col_dn, 70))
// Trend Duration (70 max)
// if barstate.islast
// if direction == 1
// label.delete(label.new(bar_index, lower, str.tostring(count_up), color = color(na), style = label.style_label_left, textcolor = chart.fg_color)[1])
// if direction == -1
// label.delete(label.new(bar_index, upper, str.tostring(count_dn), color = color(na), style = label.style_label_left, textcolor = chart.fg_color)[1])
// }
2번 **
//@version=4
study(title=" New RSI ",shorttitle = "NRSI", format=format.price, precision=0, overlay=false)
//
DZbuy = 0.1
DZsell = 0.1
Period = 14
Lb = 60
red=#f887fa
green=color.rgb(10, 193, 254)
//
RSILine = rsi(close,Period)
jh = highest(RSILine, Lb)
jl = lowest(RSILine, Lb)
jc = (wma((jh-jl)*0.5,Period) + wma(jl,Period))
Hiline = jh - jc * DZbuy
Loline = jl + jc * DZsell
R = (4 * RSILine + 3 * RSILine[1] + 2 * RSILine[2] + RSILine[3] ) / 10
//
a=plot(R, title='R', color=color.white, linewidth=1, style=plot.style_line, transp=0)
b=plot(Hiline, title='Hiline', color=color.gray, linewidth=1, style=plot.style_line, transp=0)
c=plot(Loline, title='Loline', color=color.gray, linewidth=1, style=plot.style_line, transp=0)
plot(jc, title='Jc', color=#68158e, linewidth=2, style=plot.style_line, transp=50)
//
col_1 = R > Hiline ? red:na
col_2 = R < Loline ? green:na
//
fill(a, b, color=col_1,transp=0)
fill(a, c, color=col_2,transp=0)
2025-06-09
258
글번호 191506
지표