답변완료
문의드립니다
input : atrMult(4.5);input : atrlen(12);input : rsmlen(3);input : tplen(14);var : i(0),sum(0),source(0);var : alpha(0),atrValue1(0),upperLevel(0),lowerLevel(0);var : previousLowerLevel(0),previousUpperLevel(0);var : trendDirection(Nan),superTrendValue(Nan);var : previousTrend(0);if CurrentBar > 1 Then { sum = 0; for i = 0 to rsmlen-1 { sum = sum + c[i]*c[i]; } source = sqrt(sum/rsmlen); alpha = 1 / atrlen ; atrValue1 = IFf(IsNan(atrValue1[1]) == true, ma(TrueRange,atrlen) , alpha * TrueRange + (1 - alpha) * IFf(isnan(atrValue1[1])==true,0,atrValue1[1])); upperLevel = source + atrMult * atrValue1; lowerLevel = source - atrMult * atrValue1; previousLowerLevel = iff(isnan(lowerLevel[1])==true,0,lowerLevel[1]); previousUpperLevel = iff(isnan(upperLevel[1])==true,0,upperLevel[1]); // Ensure continuity of lower and upper bands lowerLevel = iff(lowerLevel > previousLowerLevel or source[1] < previousLowerLevel , lowerLevel , previousLowerLevel); upperLevel = iff(upperLevel < previousUpperLevel or source[1] > previousUpperLevel , upperLevel , previousUpperLevel); // Determine direction and SuperTrend previousTrend = superTrendValue[1]; // Initialize direction if IsNan(atrValue1[1]) == true Then trendDirection = 1; else if previousTrend == previousUpperLevel Then trendDirection = iff(source > upperLevel , -1 , 1); else trendDirection = iff(source < lowerLevel , 1 , -1); // Set SuperTrend value based on direction superTrendValue = iff(trendDirection == -1 , lowerLevel , upperLevel);}plot1(superTrendValue,"ST", iff(trendDirection > 0 , red,green));Plot2((C+O)/2,"bodyMiddle");var : dist(0),chg(0),lvlCol(0);var : tp1(0),tp2(0),tp3(0),tp4(0),tp5(0),tp6(0),tp7(0);var : printedtp1(0),printedtp2(0),printedtp3(0),printedtp4(0),printedtp5(0),printedtp6(0),printedtp7(0);dist = abs(close-superTrendValue);lvlCol = iff(trendDirection > 0 , red , green);var : key1(0);var : key2(0);var : key3(0);var : key4(0);var : key5(0);var : key6(0);var : key7(0);if CrossUp(trendDirection, 0) or CrossDown(trendDirection, 0) Then{ //TL_Delete(keys); printedtp1 = 0; printedtp2 = 0; printedtp3 = 0; printedtp4 = 0; printedtp5 = 0; printedtp6 = 0; printedtp7 = 0; chg = abs(superTrendValue-superTrendValue[1]); tp1 = superTrendValue[1] + IFF(trendDirection > 0 , -chg , chg); tp2 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 2 , chg * 2); tp3 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 3 , chg * 3); tp4 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 4 , chg * 4); tp5 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 5 , chg * 5); tp6 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 6 , chg * 6); tp7 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 7 , chg * 7); key1 = TL_new(sdate[1],stime[1],tp1, sDate,sTime, tp1); TL_SetColor(Key1,lvlCol); TL_SetSize(Key1,2); printedtp1 = 1;}Else TL_SetEnd(key1,sDate,sTime,TP1); var : u(0),d(0),alp(0),ur(0),dr(0),rs(0),R(0),tp(False);u = max(dist - dist[1], 0);d = max(dist[1] - dist, 0);alp = 1/tplen;ur = IFf(IsNan(ur[1]) == true, ma(u,tplen) , alp * u + (1 - alp) * IFf(isnan(ur[1])==true,0,ur[1]));dr = IFf(IsNan(dr[1]) == true, ma(d,tplen) , alp * d + (1 - alp) * IFf(isnan(dr[1])==true,0,dr[1]));rs = ur / dr;R = 100 - 100 / (1 + rs);tp = CrossDown(R, 60);var : extreme(0);var : extreme_tp1_dist(0);var : extreme_tp2_dist(0);var : extreme_tp3_dist(0);var : extreme_tp4_dist(0);var : extreme_tp5_dist(0);var : extreme_tp6_dist(0);var : extreme_tp7_dist(0);extreme = iff(trendDirection > 0 , low , high);extreme_tp1_dist = abs(extreme - tp1);extreme_tp2_dist = abs(extreme - tp2);extreme_tp3_dist = abs(extreme - tp3);extreme_tp4_dist = abs(extreme - tp4);extreme_tp5_dist = abs(extreme - tp5);extreme_tp6_dist = abs(extreme - tp6);extreme_tp7_dist = abs(extreme - tp7);var : tx(0);if tp and trendDirection > 0 Then{ tx = Text_New(sDate,sTime,L,"X"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Red); Text_SetSize(tx,20); Text_SetBold(tx,1);}if tp and trendDirection < 0 Then{ tx = Text_New(sDate,sTime,H,"X"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Green); Text_SetSize(tx,20); Text_SetBold(tx,1);}if printedtp2 == 0 and extreme_tp2_dist < extreme_tp1_dist Then{ key2 = TL_new(sdate[1],stime[1],tp2, sDate,sTime, tp2); TL_SetColor(Key2,lvlCol); TL_SetSize(Key2,2); printedtp2 = 1;}Else{ if printedtp2 == 1 Then TL_SetEnd(key2,sDate,sTime,TP2);}if printedtp3 == 0 and extreme_tp3_dist < extreme_tp2_dist Then{ key3 = TL_new(sdate[1],stime[1],tp3, sDate,sTime, tp3); TL_SetColor(Key3,lvlCol); TL_SetSize(Key3,2); printedtp3 = 1;}Else{ if printedtp3 == 1 Then TL_SetEnd(key3,sDate,sTime,TP3);}if printedtp4 == 0 and extreme_tp4_dist < extreme_tp3_dist Then{ key4 = TL_new(sdate[1],stime[1],tp4, sDate,sTime, tp4); TL_SetColor(Key4,lvlCol); TL_SetSize(Key4,2); printedtp4 = 1;}Else{ if printedtp4 == 1 Then TL_SetEnd(key4,sDate,sTime,TP4);}if printedtp5 == 0 and extreme_tp5_dist < extreme_tp4_dist Then{ key5 = TL_new(sdate[1],stime[1],tp5, sDate,sTime, tp5); TL_SetColor(Key5,lvlCol); TL_SetSize(Key5,2); printedtp5 = 1;}Else{ if printedtp5 == 1 Then TL_SetEnd(key5,sDate,sTime,TP5);}if printedtp6 == 0 and extreme_tp6_dist < extreme_tp5_dist Then{ key6 = TL_new(sdate[1],stime[1],tp6, sDate,sTime, tp6); TL_SetColor(Key6,lvlCol); TL_SetSize(Key6,2); printedtp6 = 1;}Else{ if printedtp6 == 1 Then TL_SetEnd(key6,sDate,sTime,TP6);}if printedtp7 == 0 and extreme_tp7_dist < extreme_tp6_dist Then{ key7 = TL_new(sdate[1],stime[1],tp7, sDate,sTime, tp7); TL_SetColor(Key7,lvlCol); TL_SetSize(Key7,2); printedtp7 = 1;}Else{ if printedtp7 == 1 Then TL_SetEnd(key7,sDate,sTime,TP7);}수고많으십니다 문의드릴 내용은 위 수식에서 Red색 X표시가 나오면매수진입 매도청산 Red색 X표시가 계속 나오면 최대 10개까지 계속 매수진입 Green색 X표시가 나오면매도진입 매수청산 Green색 X표시가 계속 나오면 최대 10개까지 계속 매도진입이런 수식을 부탁드립니다 감사합니다
2025-12-10
170
글번호 228821
시스템
답변완료
변환 부탁 드립니다.
// © Zeiierman { //@version=6 indicator('Dynamic Swing Anchored VWAP (Zeiierman)', overlay = true, max_bars_back = 5000, max_labels_count = 500, max_polylines_count = 100) //~~}// ~~ Tooltips { var string t1 = "Number of bars used to detect swing highs and lows. Larger values identify bigger, more significant swings but react slower. Smaller values detect more frequent swings but may produce more noise." var string t2 = "Controls how quickly the VWAP adjusts to new price action. Lower values make the VWAP react faster (tighter to price), higher values make it smoother and slower to change." var string t3 = "When enabled, the VWAP reaction speed changes automatically based on market volatility. High volatility shortens the tracking period (more responsive), low volatility lengthens it (smoother)." var string t4 = "Controls how strongly volatility influences the VWAP reaction speed. Values above 1 increase the effect of volatility changes; values below 1 make it less sensitive to volatility." var string t5 = "Color used for swing high/low labels drawn on the chart to indicate pivot points." var string t6 = "Color used for swing low labels when marking pivot points." var string t7 = "Color used for VWAP lines when in an uptrend." var string t8 = "Color used for VWAP lines when in a downtrend." var string t9 = "Width of the VWAP lines drawn on the chart. Larger values make the lines thicker and more visible." //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}// ~~ Inputs { prd = input.int(50, title='Swing Period', minval=2, group='Swing Points', tooltip=t1) baseAPT = input.float(20, 'Adaptive Price Tracking', minval=1, step=1, group='Swing Points', tooltip=t2) useAdapt = input.bool(false, 'Adapt APT by ATR ratio', group='Swing Points', tooltip=t3) volBias = input.float(10.0, 'Volatility Bias', minval=0.1, step=0.1, group='Swing Points', tooltip=t4)highS = input.color(color.lime, title="Swing Labels", group="Style", inline="Swing", tooltip=t5) lowS = input.color(color.red, title="", group="Style", inline="Swing", tooltip=t6) S = input.color(color.lime, title="VWAP Lines", group="Style", inline="VWAP", tooltip=t7) R = input.color(color.red, title="", group="Style", inline="VWAP", tooltip=t8) xx = input.int(2, minval=1, title="", group="Style", inline="VWAP", tooltip=t9) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}// ~~ Global Variable { b = bar_index //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}// ~~ PIVOTS Variables { var ph = float(na) var pl = float(na) var phL = b var plL = b var lab = label(na) var prev = float(na)ph := ta.highestbars(high, prd) == 0 ? high : ph pl := ta.lowestbars(low, prd) == 0 ? low : pl phL := ta.highestbars(high, prd) == 0 ? b : phL plL := ta.lowestbars(low, prd) == 0 ? b : plL dir = phL > plL ? 1 : -1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}// ~~ Adaptation { atrLen = 50 atr = ta.atr(atrLen) atrAvg = ta.rma(atr, atrLen) ratio = atrAvg > 0 ? atr / atrAvg : 1.0aptRaw = useAdapt ? baseAPT / math.pow(ratio, volBias) : baseAPT aptClamped = math.max(5.0, math.min(300.0, aptRaw)) aptSeries = math.round(aptClamped)// alpha from APT (half-life -> EWMA alpha) alphaFromAPT(apt) => decay = math.exp(-math.log(2.0) / math.max(1.0, apt)) 1.0 - decay //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}// ~~ VWAP Variables { var p = hlc3 * volume var vol = volume type dataPoints array<chart.point> points polyline poly = navar vwap = dataPoints.new(array.new<chart.point>()) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}// ~~ Main { if dir != dir[1] x = dir > 0 ? plL : phL y = dir > 0 ? pl : ph loc = dir > 0 ? label.style_label_up : label.style_label_down col = dir > 0 ? highS : lowS txt = dir > 0 and pl < prev ? 'LL' : dir > 0 and pl > prev ? 'HL' : dir < 0 and ph < prev ? 'LH' : dir < 0 and ph > prev ? 'HH' : '' label.new(x, y, text=txt, style=loc, color=color.new(col, 20), textcolor=color.white) prev := dir > 0 ? ph[1] : pl[1] barsback = b - x p := y * volume[barsback] vol := volume[barsback] vap = p / vol vwap.poly.delete() polyline.new(vwap.points, false, false, line_color = dir < 0 ? R : S, line_width = xx) vwap.points.clear() for i = barsback to 0 by 1 apt_i = aptSeries[i] alpha = alphaFromAPT(apt_i) pxv = hlc3[i] * volume[i] v_i = volume[i] p := (1.0 - alpha) * p + alpha * pxv vol := (1.0 - alpha) * vol + alpha * v_i vappe = vol > 0 ? p / vol : na vwap.points.push(chart.point.from_index(b - i, vappe)) vwap.poly := polyline.new(vwap.points, false, false, line_color = dir < 0 ? R : S, line_width = xx)else apt_0 = aptSeries alpha = alphaFromAPT(apt_0) pxv = hlc3 * volume v0 = volume p := (1.0 - alpha) * p + alpha * pxv vol := (1.0 - alpha) * vol + alpha * v0 vap = vol > 0 ? p / vol : na vwap.poly.delete() vwap.points.push(chart.point.from_index(b, vap)) vwap.poly := polyline.new(vwap.points, false, false, line_color = dir > 0 ? R : S, line_width = xx) //~~ }
2025-12-09
371
글번호 228815
지표
답변완료
변환 부탁 드립니다.
//@version=5indicator("ALMA Smoothed Gaussian Moving Average", shorttitle = "ASGMA", overlay=true)//ALMA Smoothingsrc = input(close, title='Source', group = "ALMA Smoothing")smooth = input.int(1, title='Smoothing', minval=1, group = "ALMA Smoothing")length1 = input.int(25, title='Lookback', minval=1, group = "ALMA Smoothing")offset = 0.85sigma1 = 7pchange = ta.change(src, smooth) / src * 100avpchange = ta.alma(pchange, length1, offset, sigma1)//RSIrsi = ta.rsi(close, 14)rsiL = rsi > rsi[1]rsiS = rsi < rsi[1]//Chande Momentumlength11 = 9src1 = closemomm = ta.change(src1)f1(m) => m >= 0.0 ? m : 0.0f2(m) => m >= 0.0 ? 0.0 : -mm1 = f1(momm)m2 = f2(momm)sm1 = math.sum(m1, length11)sm2 = math.sum(m2, length11)percent(nom, div) => 100 * nom / divchandeMO = percent(sm1-sm2, sm1+sm2)cL = chandeMO > chandeMO[1]cS = chandeMO < chandeMO[1]//GAMA credit to author: © LeafAlgo https://www.tradingview.com/v/th7NZUPM/length = input.int(14, minval=1, title="Length", group = "Gaussian Adaptive Moving Average")adaptive = input.bool(true, title="Adaptive Parameters", group = "Gaussian Adaptive Moving Average")volatilityPeriod = input.int(20, minval=1, title="Volatility Period", group = "Gaussian Adaptive Moving Average")// Calculate Gaussian Moving Averagegma = 0.0sumOfWeights = 0.0sigma = adaptive ? ta.stdev(close, volatilityPeriod) : input.float(1.0, minval=0.1, title="Standard Deviation", group = "Gaussian Adaptive Moving Average")for i = 0 to length - 1 weight = math.exp(-math.pow(((i - (length - 1)) / (2 * sigma)), 2) / 2) value = ta.highest(avpchange, i + 1) + ta.lowest(avpchange, i + 1) gma := gma + (value * weight) sumOfWeights := sumOfWeights + weightgma := (gma / sumOfWeights) / 2gma:= ta.ema(gma, 7)gmaColor = avpchange >= gma ? color.rgb(0, 161, 5) : color.rgb(215, 0, 0)// Color bars based on signals until the next signal occursvar int currentSignal = 0currentSignal := avpchange >= gma ? 1 : -1//le_final ? -1 : currentSignalvar color barColor = naif currentSignal == 1 barColor := color.rgb(0, 186, 6)else if currentSignal == -1 barColor := color.rgb(176, 0, 0)barcolor(barColor)plotcandle(open, high, low, close, "Bar Color", barColor, barColor, bordercolor = barColor)//Plottingema = ta.ema(close, 7)plot(ema, color=gmaColor, linewidth=3, title="Gaussian Moving Average")plotshape(ta.crossover(avpchange,gma) and barstate.isconfirmed, "Buy Signal", text = "B", textcolor = color.white, style = shape.labelup, location = location.belowbar, color = color.rgb(0, 161, 5), offset = -1)plotshape(ta.crossunder(avpchange,gma) and barstate.isconfirmed, "Sell Signal", text = "S", textcolor = color.white, style = shape.labeldown, location = location.abovebar, color = color.rgb(215, 0, 0), offset = -1)bgcolor(ta.crossover(avpchange,gma) and barstate.isconfirmed and rsiL and cL ? color.rgb(0, 162, 5, 85): na, offset = -1)bgcolor(ta.crossunder(avpchange,gma) and barstate.isconfirmed and rsiS and cS ? color.rgb(207, 0, 0, 85): na, offset = -1)barcolor(gmaColor)alertcondition(ta.crossover(avpchange,gma) and barstate.isconfirmed, title="Buy Signal", message="Go Long! {{exchange}}:{{ticker}}")alertcondition(ta.crossunder(avpchange,gma) and barstate.isconfirmed, title="Sell Signal", message="Go Short! {{exchange}}:{{ticker}}")
2025-12-09
648
글번호 228811
지표