답변완료
문의 드립니다.
//============================================================================== // Inputs //==============================================================================smoothingLength = input.int(5, "Price Smoothing Length", group = "SuperSmoother Settings") fastLength = input.int(20, "Fast MA", group = "Moving Average Settings") slowLength = input.int(50, "Slow MA", group = "Moving Average Settings") srcMA = input.source(close, "Source Data", group = "Moving Average Settings")atrLength = input.int(20, "ATR Length", group = "Signal Generation") atrMultiplier = input.float(1.2, "ATR Multiplier", group = "Signal Generation") signalSensitivity = input.float(0.03, "Signal Sensitivity", minval=0.01, maxval=1.0, step=0.01, group = "Signal Generation")showVortexFill = input.bool(true, "Show Vortex Fill", group = "Visualization") fillTransparency = input.int(85, "Fill Transparency", minval = 0, maxval = 100, group = "Visualization") enhancedColors = input.bool(true, "Enhanced Colors", group = "Visualization")enableCandleColor = input.bool(true, "Enable Candle Coloring", group = "Candle Colors") //============================================================================== // SuperSmoother Function //==============================================================================supersmoother(src, length) => a1 = math.exp(-1.414 * 3.14159 / length) b1 = 2.0 * a1 * math.cos(1.414 * 3.14159 / length) c2 = b1 c3 = -a1 * a1 c1 = 1 - c2 - c3 ss = 0.0 ss := c1 * (src + nz(src[1])) / 2 + c2 * nz(ss[1]) + c3 * nz(ss[2]) ss//============================================================================== // Calculations //==============================================================================smoothedPrice = supersmoother(srcMA, smoothingLength) fastMA = ta.ema(smoothedPrice, fastLength) slowMA = ta.ema(smoothedPrice, slowLength)// True oscillator calculation - difference between MAs oscillator = fastMA - slowMA// Normalize oscillator for better visualization oscillatorNormalized = oscillator / ta.atr(20) * 100// Enhanced color system accel_raw = oscillator - oscillator[1] accel_smooth = ta.ema(accel_raw, 3)tanh(x) => ex = math.exp(2 * x) (ex - 1) / (ex + 1)accel_norm = tanh(accel_smooth / (ta.atr(20) * 0.01)) hue_raw = 60 + accel_norm * 60 hue = na(hue_raw[1]) ? hue_raw : (hue_raw + hue_raw[1]) / 2hsv_to_rgb(h, s, v) => c = v * s x = c * (1 - math.abs((h / 60) % 2 - 1)) m = v - c r = 0.0, g = 0.0, b = 0.0 if h < 60 r := c, g := x, b := 0 else if h < 120 r := x, g := c, b := 0 else if h < 180 r := 0, g := c, b := x else if h < 240 r := 0, g := x, b := c else if h < 300 r := x, g := 0, b := c else r := c, g := 0, b := x color.rgb(int((r + m) * 255), int((g + m) * 255), int((b + m) * 255))oscillatorColor = enhancedColors ? hsv_to_rgb(hue, 1.0, 1.0) : color.yellow// Signal line (smoothed oscillator) signalLine = ta.ema(oscillator, 25)//============================================================================== // Signal Generation - Focus on Oscillator-Signal Line Crossovers //==============================================================================atr = ta.atr(atrLength) minSignalThreshold = atr * signalSensitivity// Primary signals: Oscillator crossing above/below signal line bullishSignal = ta.crossover(oscillator, signalLine) and math.abs(oscillator - signalLine) > minSignalThreshold bearishSignal = ta.crossunder(oscillator, signalLine) and math.abs(oscillator - signalLine) > minSignalThreshold// Additional confirmation: momentum direction oscillatorMomentum = oscillator - oscillator[1] signalMomentum = signalLine - signalLine[1]// Enhanced signals with momentum confirmation strongBullishSignal = bullishSignal and oscillatorMomentum > 0 strongBearishSignal = bearishSignal and oscillatorMomentum < 0//============================================================================== // Plots //==============================================================================// Zero line reference zeroLine = hline(0, "Zero Line", color.gray, hline.style_dashed)// Main oscillator oscillatorPlot = plot(oscillator, color = oscillatorColor, title = "Oscillator", linewidth = 2)// Signal line signalColor = enhancedColors ? #FF6B35 : color.orange signalPlot = plot(signalLine, color = signalColor, title = "Signal Line", linewidth = 1)// Histogram (optional visualization) histogramColor = oscillator > signalLine ? (enhancedColors ? #00FF7F : color.green) : (enhancedColors ? #FF1493 : color.red) plot(oscillator - signalLine, color = color.new(histogramColor, 70), style = plot.style_histogram, title = "Histogram")// Zero line as plot for fill compatibility zeroLinePlot = plot(0, color = color.new(color.gray, 100), title = "Zero Line Plot")// Oscillator fills oscillatorFillColor = showVortexFill ? (oscillator > 0 ? color.new(enhancedColors ? #00FF7F : color.green, fillTransparency) : color.new(enhancedColors ? #FF1493 : color.red, fillTransparency)) : nafill(oscillatorPlot, zeroLinePlot, color = oscillatorFillColor, title = "Oscillator Fill")// Signal crossover fill crossFillColor = showVortexFill ? (oscillator > signalLine ? color.new(color.blue, fillTransparency + 10) : color.new(color.purple, fillTransparency + 10)) : nafill(oscillatorPlot, signalPlot, color = crossFillColor, title = "Signal Fill")// Updated Signal Plots - Focus on Crossover Signals plotshape(bullishSignal, "Buy Signal", shape.triangleup, location.belowbar, color.green, 0, size = size.small, force_overlay = true) plotshape(bearishSignal, "Sell Signal", shape.triangledown, location.abovebar, color.red, 0, size = size.small, force_overlay = true)// Strong signals with momentum confirmation plotshape(strongBullishSignal, "Strong Buy", shape.triangleup, location.belowbar, color.lime, 0, size = size.normal, force_overlay = true) plotshape(strongBearishSignal, "Strong Sell", shape.triangledown, location.abovebar, color.maroon, 0, size = size.normal, force_overlay = true)// Signal line crossover areas for additional context bgcolor(bullishSignal ? color.new(color.green, 95) : na, title = "Bullish Signal BG") bgcolor(bearishSignal ? color.new(color.red, 95) : na, title = "Bearish Signal BG")// Candle plot based on signal convergence and divergence // Determine candle color based on oscillator position relative to signal line candleColor = if not enableCandleColor na else if oscillator > signalLine color.green else if oscillator < signalLine color.red else color.gray// Apply candle coloring barcolor(candleColor, title = "Candle Color")위 수식에서 히스토그램은 빼고 두 라인선만 추출해서 예스 지표로 만들어주시고 그 두 선이 교차할때 매수/매도 신호가 나오는 시스템 수식도 하나 더 만들어주세요.
2025-12-01
118
글번호 228493
지표
답변완료
수식 압축하는 방법
1.전에 만들어 주신 파라볼릭 계산하는 수식입니다. 이게 변수 바로 아래 너무 길게 있어서 변수하고 진입과 청산식을 한번에 보기가 어렵습니다. 혹시 단 몇줄로 압축한다든가 하는 방법이 있으면 좀 알려주세요! if EP != 0 Then { if Direction == 1 then { EP = HighValue; SAR_Value = SAR_Value + AF_Value * (EP - SAR_Value); if High > HighValue then { HighValue = High; AF_Value = AF_Value + AF; if AF_Value >= AFmaX then AF_Value = AFmaX; } if Low < SAR_Value then { Direction = -1; SAR_Value = EP; AF_Value = 0; EP = 0; LowValue = low; } } else { EP = LowValue; SAR_Value = SAR_Value + AF_Value * (EP - SAR_Value); if Low < LowValue then { LowValue = Low; AF_Value = AF_Value + Af; if AF_Value >= AFmaX then AF_Value = AFmaX; } if High > SAR_Value then { Direction = 1; SAR_Value = EP; AF_Value = 0; EP = 0; HighValue = High; } } Sarv = SAR_Value; } else { if SAR_Value != 0 && EP == 0 then { if Direction == 1 then { EP = HighValue; AF_Value = AF; SAR_Value = SAR_Value + AF_Value * (EP - SAR_Value); if High > HighValue then { HighValue = High; AF_Value = AF_Value + AF; if AF_Value >= AFmaX then AF_Value = AFmaX; } } else { EP = LowValue; AF_Value = Af; SAR_Value = SAR_Value + AF_Value * (EP - SAR_Value); if Low < LowValue then { LowValue = Low; AF_Value = AF_Value + AF; if AF_Value >= AFmaX then AF_Value = AFmaX; } } Sarv = SAR_Value; } else { if Direction == 0 then { if Close > Close[1] then Direction = 1; else if Close < Close[1] then Direction = -1; } else { if Direction == 1 then { if Close < Close[1] then { Direction = -1; SAR_Value = HighValue; Sarv = SAR_Value; } } if Direction == -1 then { if Close > Close[1] then { Direction = 1; SAR_Value = LowValue; Sarv = SAR_Value; } } } LowValue = min(Low, LowValue); HighValue = max(High, HighValue); } 2..일봉상 ema를 가져오고 60분봉상 adx를 가져와서 시장판단만 하고 지표계산은 60분봉으로 하여60분봉으로 진입청산식을 만드는게 가능한가요? 예를 들면 아래와 같이 Var :DailyEMA200(0), ADX(0),regime(0); DailyEMA200 = EMA(Close of Data2, 200); (60분봉상 )ad = ADX(14 ); Regime = 0; { 1=상승장, -1=하락장/폭락장, 0=횡보 } If Close of Data2 > DailyEMA200 and ADX > 20 then Regime = 1 { 상승장 } Else If Close of Data2 < DailyEMA200 and ADX > 20 then Regime = -1 { 하락장 } Else Regime = 0 { 횡보 / 박스권 } 시장판단을 하고 { --- 60분봉상 메인 지표 계산 --- } Var Sarv(0), MC(0), MS(0), OS(0); Sarv = SAR(0.02, 0.2); MC = MACD(10,21); MS = EMA(MC,7); OS = MC - MS; If Regime = 1 and CrossUp(Close, Sarv) and OS > 0 and Close > Close[1] then Begin Buy("Long") next bar at market; 만약 위의 식이 잘못 되었다면 일봉의 데이터를 적용하고 분봉상으로 매매진입하는 방법을 좀 알려주세요 3.. mvar1 = Sarv+(AF_value)*(EP-SAR_Value); mvar2 = MAX(var1,EntryPrice- EntryATR*ATr1); mvar3 = Min(var1,EntryPrice+ EntryATR*1.5); if marketPosition == -1 and Direction == -1 Then { ExitShort("sx1",AtStop,mvar3); ExitShort("sx3",AtLimit,EntryPrice-entryatr*5,"",1,1); } 이 청산식은 파라볼릭반전신호와 atr*1.5 중 비교하여 으로 손절을하라는 내용과 파라볼릭반전신호와 atr*5값중에서 둘중에 먼저 도달하는 지표에 청산하라는 내용이 다 들어간게 맞는건가요? 요지는 파라볼릭 돌파가 손절과 익절에 모두 작동하는지요? 질문이 너무 길어서 죄송합니다.