답변완료
지표 변환 부탁드립니다.
//@version=6
//-----------------------------------------------------------------------------
// NeuroTrend – Adaptive AI Trend Engine
//
//:
// NeuroTrend is an adaptive, AI-assisted trend indicator designed for momentum
// and swing trading. It uses dynamic EMAs, slope forecasting, neural memory,
// and a trend classification engine to deliver real-time insights. The system
// includes confidence scoring, reversal detection, and a premium visual dashboard.
//
// Key Features:
// • Adaptive EMA smoothing based on volatility and momentum conditions
// • Real-time slope angle, power, and projected trend forecasts
// • Neural memory system for volatility-aware threshold calibration
// • Classification of trend phases: Impulse, Cooling, Reversal, Stall, Neutral
// • Confidence score derived from DMI, slope, and volatility ratio
// • Reversal and stall zone detection with alert labeling
// • AI-style commentary with smart coaching logic
// • Compact dashboard with all trend diagnostics in one view
//
// Usage:
// Best used to time entries
// into strong trend conditions, confirm trend continuation, or detect exhaustion
// before reversals.
//
// Author: AresIQ
// License: Mozilla Public License 2.0
// Terms: This open-source 스크립트 may be modified and reused with attribution.
//
// Link to License: https://www.mozilla.org/en-US/MPL/2.0/
//-----------------------------------------------------------------------------
indicator("NeuroTrend", overlay=true)
// USER INPUTS ₩₩
enableReflex = input.bool(false, "Enable Reflex Mode", inline="reflex", group="Turbo Mode")
showCommentary = input.bool(true, "Show AI Commentary", inline="ai", group="Neuro Settings")
tablePosition = input.string("Top Right", "Dashboard Position", options=["Top Left", "Top Middle", "Top Right", "Bottom Left", "Bottom Middle", "Bottom Right"], group="Neuro Settings")
pos = tablePosition == "Top Left" ? position.top_left :
tablePosition == "Top Middle" ? position.top_center :
tablePosition == "Top Right" ? position.top_right :
tablePosition == "Bottom Left" ? position.bottom_left :
tablePosition == "Bottom Middle" ? position.bottom_center :
position.bottom_right
commentaryTextColor = input.color(color.white, "Commentary Text Color", inline="commentaryColor", group="Neuro Settings")
tableTextColor = input.color(color.white, "Dashboard Text Color", group="Neuro Settings")
baseFast = input.int(10, "Base Fast EMA")
baseSlow = input.int(21, "Base Slow EMA")
showConfidence = input.bool(true, "Show Confidence Score", inline="conf", group="Neuro Settings")
showReversal = input.bool(true, "Show Reversal Warnings", inline="rev", group="Neuro Settings")
showStall = input.bool(true, "Show Stall Alerts", inline="stall", group="Neuro Settings")
showProjection = input.bool(true, "Show Slope Projection", inline="proj", group="Neuro Settings")
enableAlerts = input.bool(true, "Enable Smart Alerts", inline="alerts", group="Alerts")
// CUSTOM ALERT BUILDER ₩₩
customEnableAlerts = input.bool(false, "Enable Custom Alerts", group="Alerts")
customMinConfidence = input.int(60, "Min Confidence", minval=0, maxval=100, group="Alerts")
customRequireImpulse = input.bool(true, "Require Impulse", group="Alerts")
customRequireBullish = input.bool(false, "Only Bullish Trends", group="Alerts")
customRequireBearish = input.bool(false, "Only Bearish Trends", group="Alerts")
customBlockReversal = input.bool(true, "Ignore Reversal Risk", group="Alerts")
customBlockStall = input.bool(false, "Ignore Stall", group="Alerts")
// SESSION PHASE DETECTION ₩₩
hourNow = hour(time)
minuteNow = minute(time)
sessionMinute = (hourNow - 9) * 60 + minuteNow - 30 // 0 at 9:30 AM
sessionPhase = sessionMinute < 90 ? "⏰ Morning Drive" :
sessionMinute < 270 ? "😴 Midday Drift" :
sessionMinute <= 390 ? "⚡ Power Hour" :
"⏳ After Hours"
// CONTEXT ₩₩
atr = ta.atr(14)
rsi = ta.rsi(close, 14)
volFactor = atr / close
momentumFactor = (rsi - 50) / 100
// ADAPTIVE LENGTHS ₩₩
fastLen = enableReflex ? baseFast * 0.75 : baseFast - volFactor * 5 + momentumFactor * 5
slowLen = enableReflex ? baseSlow * 0.85 : baseSlow + volFactor * 5 - momentumFactor * 5
alphaFast = 2.0 / (fastLen + 1.0)
alphaSlow = 2.0 / (slowLen + 1.0)
// ADAPTIVE EMA FUNCTION ₩₩
adaptiveEMA(src, alpha) =>
var float result = na
result := na(result[1]) ? src : alpha * src + (1 - alpha) * result[1]
// EMAS ₩₩
emaFast = adaptiveEMA(close, alphaFast)
emaSlow = adaptiveEMA(close, alphaSlow)
// SLOPE METRICS ₩₩
slopeDeg = math.atan(emaFast - emaSlow) * 180 / math.pi
slopePower = enableReflex ? slopeDeg * (1 + volFactor * 0.5 + momentumFactor * 1.5) : slopeDeg * (1 + volFactor + momentumFactor)
glowIntensity = math.min(math.abs(slopePower), 50)
// COLOR ENGINE ₩₩
baseColor = slopePower > 0 ? color.rgb(38, 230, 0) : color.rgb(168, 45, 36)
// RENDER LAYERS ₩₩
glowBase = slopePower > 0 ? color.rgb(80, 255, 100) : color.rgb(255, 70, 70)
coreColor = color.new(glowBase, 0)
glow1 = color.new(glowBase, 75)
glow2 = color.new(glowBase, 85)
shadowTrail = color.new(glowBase, 92)
plot(emaFast, title="Fast EMA Core", color=coreColor, linewidth=3)
plot(emaFast, title="Glow Layer 1", color=glow1, linewidth=6)
plot(emaFast, title="Glow Layer 2", color=glow2, linewidth=9)
plot(emaSlow, title="Slow EMA", color=color.new(glowBase, 80), linewidth=2)
plot(emaFast[5], title="Shadow Trail", color=shadowTrail, linewidth=1, style=plot.style_line)
// FILLS ₩₩
fill(plot(emaFast), plot(emaSlow), color=color.new(glowBase, 90), title="Trend Ribbon Fill")
// NEURAL MEMORY ENGINE ₩₩
atrMemory = ta.sma(atr, enableReflex ? 20 : 50)
slopeStdDev = ta.stdev(slopePower, enableReflex ? 20 : 50)
volatilityState = (atr / atrMemory + slopeStdDev / 30) / 2
volatilityFactor = math.min(math.max(volatilityState, 0.5), 1.5)
// Auto-calibrated thresholds
impulseThreshold = 40 * volatilityFactor
coolingThreshold = 20 * volatilityFactor
stallSlopeLimit = 10 * volatilityFactor
rsiFlatMin = 48 - (5 * (volatilityFactor - 1))
rsiFlatMax = 52 + (5 * (volatilityFactor - 1))
// TREND STATE CLASSIFIER ₩₩
isImpulse = math.abs(slopePower) > impulseThreshold
isCooling = math.abs(slopePower) > coolingThreshold and math.abs(slopePower) <= impulseThreshold
isNeutral = math.abs(slopePower) <= 20
isReversal = ta.change(slopeDeg, 1) < -30 or ta.rsi(close, 14) < 40
trendDir = slopePower > 0 ? "Bullish" : "Bearish"
// TREND AGE & DECAY ₩₩
var int trendAge = 0
trendAge := trendDir == trendDir[1] ? trendAge + 1 : 1
decayFactor = math.max(1.0 - trendAge / 100, 0.5) // Caps decay at 50%
trendColor = slopePower > 0 ? color.lime : color.red
phaseText = isImpulse ? "🔥 Impulse" : isCooling ? "🌀 Cooling" : isReversal ? "⚠️ Reversal Risk" : "⛔ Neutral"
// PHASE MEMORY ENGINE ₩₩
var string prevPhase = na
phaseChanged = not na(prevPhase) and phaseText != prevPhase
prevPhase := phaseText
slopeScore = math.round(math.abs(slopePower) * 2)
// CONFIDENCE SCORING ENGINE ₩₩
[plusDI, minusDI, adx] = ta.dmi(14, 14)
trendStrength = math.min(adx, 50) / 50
directionBias = math.abs(plusDI - minusDI) / 100
volatilityRatio = math.min(atr / math.abs(emaFast - emaSlow), 3.0) / 3.0
slopeNorm = math.min(math.abs(slopePower), 50) / 50
// CONFIDENCE SCORE ₩₩
confidenceRaw = (trendStrength + directionBias + slopeNorm + (1 - volatilityRatio)) / 4
confidenceScore = math.round(confidenceRaw * 100 * decayFactor)
confidenceLabel = confidenceScore >= 75 ? "High" : confidenceScore >= 50 ? "Medium" : "Low"
// REVERSAL SENSOR ENGINE ₩₩
slopeFlipping = ta.change(math.sign(slopePower)) != 0
slopeCollapsing = math.abs(slopePower) < 10
rsiDro*pping = rsi < 45
reversalRisk = (slopeFlipping and slopeCollapsing) or (rsiDro*pping and slopePower < 0)
// REVERSE SYMMETRY ₩₩
isBullishReversal = reversalRisk and slopePower > 30 and close > emaFast and close > emaSlow
isBearishReversal = reversalRisk and slopePower < -30 and close < emaFast and close < emaSlow
isReversingNow = isBullishReversal or isBearishReversal
reversalLabel = isBullishReversal ? "🚀 Bullish Reversal" : isBearishReversal ? "🚨 Bearish Reversal" : reversalRisk ? "⚠️ Reversal Threat" : "✅ Stable"
// RECOVERY DETECTION ENGINE ₩₩
wasBearish = trendDir[1] == "Bearish"
emaCrossover = close > emaFast and close[1] < emaFast[1] and close > emaSlow
recoveryBounce = isBullishReversal and wasBearish and emaCrossover
// STALL DETECTOR ENGINE ₩₩
slopeLow = math.abs(slopePower) < stallSlopeLimit
rsiFlat = rsi > rsiFlatMin and rsi < rsiFlatMax
atrCompression = atr < ta.sma(atr, 20)
stallDetected = rsiFlat and slopeLow and atrCompression
stallLabel = stallDetected ? "🛑 Dead Zone" : "✅ Active"
// SLOPE PROJECTION ENGINE ₩₩
slopeNow = slopeDeg
slopePrev = math.atan(emaFast[1] - emaSlow[1]) * 180 / math.pi
slopeDelta = slopeNow - slopePrev
slopeAccel = slopeDelta - (slopePrev - math.atan(emaFast[2] - emaSlow[2]) * 180 / math.pi)
slopeForecast = slopeNow + slopeDelta + slopeAccel
// ADAPTIVE SLOPE CLAMPING ENGINE ₩₩
baseClamp = 45.0
dynamicRange = 15.0
forecastVolatilityFactor = math.min(math.max((atr / ta.sma(atr, 50) + ta.stdev(slopePower, 50) / 30) / 2, 0.5), 1.5)
adaptiveClamp = baseClamp + (forecastVolatilityFactor - 1.0) * dynamicRange
slopeForecastClamped = math.max(math.min(slopeForecast, adaptiveClamp), -adaptiveClamp)
// SLOPE PROJECTION CONFIDENCE ₩₩
slopeMomentum = math.abs(slopeAccel)
forecastConfidence = slopeMomentum > 2.5 ? "High" : slopeMomentum > 1.0 ? "Medium" : "Low"
projectionLabel = slopeForecastClamped > 15 ? "📈 Rising" : slopeForecastClamped < -15 ? "📉 Falling" : "➖ Sideways"
projectionValue = " (" + str.tostring(math.round(slopeForecastClamped)) + "°, " + forecastConfidence + " Confidence)"
// MOMENTUM FADING DETECTION ₩₩
slopeFading = ta.change(slopePower) < 0 and not stallDetected and not reversalRisk and math.abs(slopePower) > 15
momentumFading = slopeFading and slopePower[1] > slopePower[2] and slopePower > 10
// SMART ENTRY WINDOW DETECTION ₩₩
impulseActive = isImpulse and slopePower > 20 and confidenceScore >= 60
pulledBack = close[1] < emaFast[1] and close > emaFast and low < emaFast
smartEntryWindow = impulseActive and pulledBack
plotshape(smartEntryWindow, title="Smart Entry", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.teal)
// COMMENTARY GENERATOR ₩₩
aiCommentary = phaseChanged ? "🔄 Phase Shift: " + prevPhase + " → " + phaseText :
recoveryBounce ? "🔁 Recovery rally — bounce reclaiming trend structure. (" + sessionPhase + ")" :
smartEntryWindow ? "🎯 Smart entry window — impulse pullback with reclaim. (" + sessionPhase + ")" :
momentumFading ? "🪫 Momentum weakening — trend may lose steam soon. (" + sessionPhase + ")" :
isImpulse and confidenceScore >= 75 and not reversalRisk ? "📈 Strong trend forming — consider riding momentum. (" + sessionPhase + ")" :
isCooling and confidenceScore >= 50 ? "🌀 Trend slowing — caution if already in position. (" + sessionPhase + ")" :
stallDetected and not isImpulse ? "⏸️ Price stalling — this is not the time to enter. (" + sessionPhase + ")" :
isBullishReversal ? "🚀 Bullish reversal confirmed — breakout in progress. (" + sessionPhase + ")" :
isBearishReversal ? "🚨 Bearish reversal confirmed — breakdown in progress. (" + sessionPhase + ")" :
reversalRisk and confidenceScore < 50 ? "⚠️ Reversal threat building — watch for breakdown or bounce. (" + sessionPhase + ")" :
confidenceScore < 30 ? "🧪 Low conviction trend — better to wait for clarity. (" + sessionPhase + ")" :
"➖ Trend steady — no action required right now. (" + sessionPhase + ")"
var label commentaryLabel = na
if showCommentary and not na(high)
if not na(commentaryLabel)
label.delete(commentaryLabel)
commentaryLabel := showCommentary and not na(high) ? label.new(bar_index, math.max(high, high[1], high[2]) + atr * 1.5, aiCommentary, xloc.bar_index, yloc.price, style=label.style_label_center, size=size.normal, textcolor=commentaryTextColor, color=color.new(#eece89, 85), textalign=text.align_center, tooltip="NeuroTrend Commentary") : commentaryLabel
// DASHBOARD RENDERING ₩₩
var table dashboard = table.new(pos, 7, 2, border_width=1, frame_color=color.new(color.white, 90), bgcolor=color.new(color.navy, 95))
if bar_index % 5 == 0
table.cell(dashboard, 0, 0, "🧠 Phase", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small)
table.cell(dashboard, 0, 1, phaseText, text_color=tableTextColor, bgcolor=color.new(trendColor, 20), text_size=size.small)
table.cell(dashboard, 1, 0, "📈 Direction", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small)
table.cell(dashboard, 1, 1, trendDir, text_color=tableTextColor, bgcolor=color.new(trendColor, 10), text_size=size.small)
table.cell(dashboard, 2, 0, "🔋 Slope Power", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small)
table.cell(dashboard, 2, 1, str.tostring(slopeScore) + " / 100", text_color=tableTextColor, bgcolor=color.new(trendColor, 85), text_size=size.small)
if showConfidence
table.cell(dashboard, 3, 0, "🧠 Confidence", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small)
table.cell(dashboard, 3, 1, confidenceLabel + " (" + str.tostring(confidenceScore) + ")", text_color=tableTextColor, bgcolor=color.new(trendColor, 80), text_size=size.small)
if showReversal
table.cell(dashboard, 4, 0, "🚨 Reversal Risk", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small)
table.cell(dashboard, 4, 1, reversalLabel, text_color=tableTextColor, bgcolor=reversalRisk ? color.new(color.red, 60) : color.new(color.green, 80), text_size=size.small)
if showStall
table.cell(dashboard, 5, 0, "⏸️ Momentum", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small)
table.cell(dashboard, 5, 1, stallLabel, text_color=tableTextColor, bgcolor=stallDetected ? color.new(color.orange, 60) : color.new(color.green, 80), text_size=size.small)
if showProjection
table.cell(dashboard, 6, 0, "📡 Projection", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small)
table.cell(dashboard, 6, 1, projectionLabel + projectionValue, text_color=tableTextColor, bgcolor=color.new(trendColor, 70), text_size=size.small)
// SMART ALERT CONDITION ₩₩
customAlertCondition =
customEnableAlerts and
confidenceScore >= customMinConfidence and
(not customRequireImpulse or isImpulse) and
(not customRequireBullish or slopePower > 0) and
(not customRequireBearish or slopePower < 0) and
(not customBlockReversal or not reversalRisk) and
(not customBlockStall or not stallDetected)
alertcondition(customAlertCondition, title="Custom NeuroTrend Alert", message="🔔 NeuroTrend: Your custom alert conditions have been met.")
// BUY / SELL SIGNAL LABELS ₩₩
showBuySellLabels = input.bool(true, "Show Buy/Sell Labels", group="Neuro Settings")
buySignal = ta.crossover(slopeDeg, 0) and slopePower > 0
sellSignal = ta.crossunder(slopeDeg, 0) and slopePower < 0
if showBuySellLabels
if buySignal
label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white, yloc=yloc.belowbar)
if sellSignal
label.new(bar_index, high, "SELL", style=label.style_label_down, color=color.red, textcolor=color.white, yloc=yloc.abovebar)
2025-05-15
569
글번호 190852
지표