답변완료
종목검색식 부탁드림니다.
항상 노고에 감사드림니다.
아래의 수식을 종목검색식으로 부탁드림니다.
가중12 = ma(C,12,가중);
가중60 = ma(C,60,가중);
이동120 = ma(C,120);
저점 = 가중12>가중12(1) && 가중12(1)<가중12(2);
고점 = Highestsince(1, 저점,H);
첫바닥12 = Valuewhen(1, 저점,가중12(1));
첫바닥60 = Valuewhen(1, 저점,가중60(1));
쌍바닥12 = Valuewhen(1, 저점,가중12(1));
쌍바닥60 = Valuewhen(1, 저점,가중60(1));
전고점 = Valuewhen(1, 저점, 고점(1));
첫바닥12<첫바닥60 &&
쌍바닥12<첫바닥60 &&
가중60 <가중12 &&
Crossup(H, 전고점) &&
C>이동120 &&
C>O
2024-10-26
665
글번호 184630
종목검색
답변완료
수고하십니다
항상감사드리며
트레이딩뷰 챠트인데 간곡히 변환 부탁드립니다
indicator("Market Structure Algo", "MS Algo", true)
left = input.int(5, "Internal MS", minval = 2)
left1 = input.int(30, "External MS", minval = 7)
dist = input.float(2.00, "Zone Distance", minval = 1, step = 0.1, inline = "zone")
zone = input.bool(true, "", inline = "zone")
right = left
right1 = left1
upcolor = input.color(#2962ff, "Positive color", group = "Appearence")
downcolor = input.color(#e91e63, "Negative color", group = "Appearence")
// Internal
pvh = ta.pivothigh(left, right)
pvl = ta.pivotlow(left, right)
var float ph = na
var float pl = na
ph := pvh != 0 ? pvh : ph[1]
pl := pvl != 0 ? pvl : pl[1]
currenth = ta.valuewhen(pvh != 0, high[right], 0)
lasth = ta.valuewhen(pvh != 0, high[right], 1)
currentl = ta.valuewhen(pvl != 0, low[right], 0)
lastl = ta.valuewhen(pvl != 0, low[right], 1)
var int ms = na
ms := if currenth > lasth and currentl > lastl and close > ph
ms := 2
else if close > ph
ms := 1
else if currenth < lasth and currentl < lastl and close < pl
ms := -2
else if close < pl
ms := -1
else
ms[1]
var int last = na
longsig = close > ph and ms[1] < 0
shortsig = close < pl and ms[1] > 0
longsig1 = close > ph and ms[1] > 0
shortsig1 = close < pl and ms[1] < 0
longsig2 = longsig1 and longsig1[1] == false and longsig[1] == false
shortsig2 = shortsig1 and shortsig1[1] == false and shortsig[1] == false
longexit = high > ph and close < ph
shortexit = low < pl and close > pl
// External
pvh1 = ta.pivothigh(left1, right1)
pvl1 = ta.pivotlow(left1, right1)
var float ph1 = na
var float pl1 = na
ph1 := pvh1 != 0 ? pvh1 : ph1[1]
pl1 := pvl1 != 0 ? pvl1 : pl1[1]
// Zone
ma = ta.sma(close, left1)
atr = ta.atr(left1)
ma2 = ms > 0 and ms[1] > 0 ? ma - atr * dist : ms < 0 and ms[1] < 0 ? ma + atr*dist : na
ma3 = ms > 0 and ms[1] > 0 ? ma2 + atr : ms < 0 and ms[1] < 0 ? ma2 - atr : na
// Plot
if pvh != 0
l1 = line.new(x1 = bar_index - right, y1 = ph, x2 = bar_index + math.round(right/2), y2 = ph, color = color.new(upcolor, 50), style = line.style_dashed)
if pvl != 0
l2 = line.new(x1 = bar_index - right, y1 = pl, x2 = bar_index + math.round(right/2), y2 = pl, color = color.new(downcolor, 50), style = line.style_dashed)
if pvh1 != 0
l3 = line.new(x1 = bar_index - right1, y1 = ph1, x2 = bar_index + math.round(right1/2), y2 = ph1, color = upcolor, width = 2)
if pvl1 != 0
l4 = line.new(x1 = bar_index - right1, y1 = pl1, x2 = bar_index + math.round(right1/2), y2 = pl1, color = downcolor, width = 2)
barcolor(ms >= 2 ? upcolor : ms == 1 ? color.new(upcolor, 50) : ms <= -2 ? downcolor : ms == -1 ? color.new(downcolor, 50) : na)
plotshape(longsig, "Long Signal", shape.labelup, location.belowbar, upcolor, 0, "↑", textcolor = color.new(color.white, 50))
plotshape(longsig2, "Buy Signal", shape.triangleup, location.belowbar, upcolor)
plotshape(shortsig, "Short Signal", shape.labeldown, location.abovebar, downcolor, 0, "↓", textcolor = color.new(color.white, 50))
plotshape(shortsig2, "Sell Signal", shape.triangledown, location.abovebar, downcolor)
plotshape(longexit, "Long Exit", shape.triangledown, location.abovebar, color.gray)
plotshape(shortexit, "Short Exit", shape.triangleup, location.belowbar, color.gray)
p1 = plot(zone ? ma2 : na, "External Zone", close > ma2 ? upcolor : close < ma2 ? downcolor : na, 1, plot.style_linebr)
p2 = plot(zone ? ma3 : na, "Internal Zone", close > ma2 ? color.new(upcolor, 80) : close < ma2 ? color.new(downcolor, 80) : na, 1, plot.style_linebr)
fill(p1, p2, color = close > ma2 ? color.new(upcolor, 80) : color.new(downcolor, 80), title = "Zone fill")
alertcondition(longsig, "Long CHoCH")
alertcondition(shortsig, "Short CHoCH")
alertcondition(longsig2, "Long BOS")
alertcondition(shortsig2, "Short BOS")
2024-10-26
871
글번호 184626
지표
답변완료
트레이딩뷰 사용중인 Zero-Lag MA Trend Levels 수정요망
항상 감사드립니다..
트레이딩뷰 사이트에서 제공하여 사용중인 아래의 수식을 예스스탁에서 사용할수 있도록 수식을 부탁 드립니다.
indicator("Zero-Lag MA Trend Levels [ChartPrime]", overlay = true)
// --------------------------------------------------------------------------------------------------------------------}
// 𝙐𝙎𝙀𝙍 𝙄𝙉𝙋𝙐𝙏𝙎
// --------------------------------------------------------------------------------------------------------------------{
int length = input.int(15, title="Length") // Length for the moving average calculations
bool show_levl = input.bool(true, "Trend Levels") // Toggle to show trend levels
// Colors for the trend levels
color up = input.color(#30d453, "+", group = "Colors", inline = "i")
color dn = input.color(#4043f1, "-", group = "Colors", inline = "i")
var box1 = box(na) // Variable to store the box
series float atr = ta.atr(200) // Average True Range (ATR) for trend levels
// --------------------------------------------------------------------------------------------------------------------}
// 𝙄𝙉𝘿𝙄𝘾𝘼𝙏𝙊𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
// --------------------------------------------------------------------------------------------------------------------{
series float emaValue = ta.ema(close, length) // EMA of the closing price
series float correction = close + (close - emaValue) // Correction factor for zero-lag calculation
series float zlma = ta.ema(correction, length) // Zero-Lag Moving Average (ZLMA)
bool signalUp = ta.crossover(zlma, emaValue) // Signal for bullish crossover
bool signalDn = ta.crossunder(zlma, emaValue) // Signal for bearish crossunder
// Determine the color of ZLMA based on its direction
color zlma_color = zlma > zlma[3] ? up : zlma < zlma[3] ? dn : na
color ema_col = emaValue < zlma ? up : dn // Determine the EMA color
// --------------------------------------------------------------------------------------------------------------------}
// 𝙑𝙄𝙎𝙐𝘼𝙇𝙄𝙕𝘼𝙏𝙄𝙊𝙉
// --------------------------------------------------------------------------------------------------------------------{
// Plot the Zero-Lag Moving Average
p1 = plot(zlma, color = zlma_color, linewidth = 1) // Plot ZLMA
p2 = plot(emaValue, color = ema_col, linewidth = 1) // Plot EMA
fill(p1, p2, zlma, emaValue, color.new(zlma_color, 80), color.new(ema_col, 80)) // Fill between ZLMA and EMA
// Method to draw a box on the chart
method draw_box(color col, top, bot, price)=>
box.new(
bar_index, top, bar_index, bot, col, 1,
bgcolor = color.new(col, 90),
text = str.tostring(math.round(price, 2)),
text_size = size.tiny,
text_color = chart.fg_color,
text_halign = text.align_right
)
// Logic to draw trend levels as boxes on the chart
if show_levl
bool check_signals = signalUp or signalDn // Check if there is an up or down signal
switch
// Draw a box when a bullish signal is detected
signalUp => box1 := up.draw_box(zlma, zlma - atr, close)
// Draw a box when a bearish signal is detected
signalDn => box1 := dn.draw_box(zlma + atr, zlma, close)
switch
// Extend the right side of the box if no new signal is detected
not signalUp or not signalDn => box1.set_right(bar_index + 4)
=> box1 := box(na) // Otherwise, reset the box
switch
// Add a downward label when price crosses below the bottom of the box
ta.crossunder(high, box1.get_bottom()) and not check_signals[1] and not check_signals and emaValue > zlma=>
label.new(bar_index - 1, high[1], "▼", color = color(na), textcolor = dn, style = label.style_label_down)
// Add an upward label when price crosses above the top of the box
ta.crossover(low, box1.get_top()) and not check_signals and not check_signals[1] and emaValue < zlma=>
label.new(bar_index - 1, low[1], "▲", color = color(na), textcolor = up, style = label.style_label_up)
// Plot shapes for up and down signals
plotshape(signalUp ? zlma : na, "", shape.diamond, location.absolute, color = up, size = size.tiny)
plotshape(signalDn ? zlma : na, "", shape.diamond, location.absolute, color = dn, size = size.tiny)
// --------------------------------------------------------------------------------------------------------------------}
2024-10-25
1077
글번호 184618
시스템