institutional Signal Flow [Quantum Edge]

Quantum-Edge-Capital · study · 162 行 · 点赞 8 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Quantum-Edge-Capital
//@version=6
indicator(' institutional Signal Flow [Quantum Edge]', overlay = false)
 
//              ╔════════════════════════════════╗              //
//              ║      USER-DEFINED SETTINGS     ║              //
//              ╚════════════════════════════════╝              //
 
var string calculation_settings = '════════ Calculation Parameters ════════'
var string visual_settings = '════════ Visualization Settings ════════'
 
tooltip_source = 'The price data used for Smart Money Flow calculations. HLC3 (default) provides balanced signals using High, Low, and Close average. Close uses only closing prices for end-of-bar signals. HL2 uses the midpoint between High and Low. OHLC4 incorporates all price points for the most comprehensive view. Each source affects sensitivity to intraday price movements and influences the responsiveness of all money flow components.'
tooltip_momentum = 'Period for momentum wave channel calculation. Shorter periods (5-10) create more responsive signals that react quickly to price changes, useful for capturing early momentum shifts. Longer periods (15-20) smooth out noise and focus on sustained momentum, better for filtering false signals. Default 10 balances responsiveness with reliability across most timeframes.'
tooltip_trend = 'Main period for money flow, volume, and buying/selling pressure calculations. This is the foundation period affecting multiple components of the indicator. Shorter periods (10-14) capture short-term institutional activity and rapid shifts. Longer periods (21-30) identify major trend shifts and sustained institutional accumulation or distribution. Standard value is 21 for intermediate-term swing trading analysis.'
tooltip_mfi = 'Period for Money Flow Index calculation, which measures buying and selling pressure using price and volume. Shorter periods (7-10) detect rapid shifts in money flow and institutional sentiment. Standard period is 14 (RSI equivalent) for balanced signals. Longer periods (20-25) smooth out the index and focus on sustained money flow trends, reducing whipsaws in choppy conditions.'
tooltip_smoothing = 'EMA smoothing applied to the final composite wave to reduce noise and create clearer, more actionable trend signals. Lower values (1-3) preserve more price detail and react faster to money flow changes but may show more fluctuations. Higher values (5-10) create smoother, more stable trend lines with fewer false reversals but slower response to genuine shifts. Set to 1 for no additional smoothing (raw composite signal).'
tooltip_preset = 'Select a predefined configuration optimized for different trading styles, timeframes, and market conditions.'
tooltip_preset_details = 'Default (10, 21, 14, 4): Balanced configuration suitable for swing trading on 4H and daily charts. Standard periods provide reliable signals with moderate smoothing. Works well in most market conditions with balanced sensitivity to institutional money flow movements. Optimal for intermediate-term position management.\n\nFast Response (7, 14, 10, 2): Aggressive configuration for active intraday trading and scalping on 1min-1H charts. Shorter periods across all components, tighter MFI, and minimal smoothing catch rapid institutional money flow changes and quick trend shifts. Best for capturing early entries and exits. Expect more frequent signals and some whipsaws during consolidation periods.\n\nSmooth Trend (14, 30, 21, 7): Conservative configuration for position trading and long-term analysis on daily and weekly charts. Extended periods across all components with heavy smoothing filter out short-term market noise to identify only strong, sustained institutional accumulation and distribution phases. Ideal for longer-term trend following with minimal false reversals and high-confidence signals.'
tooltip_overbought = 'Upper threshold level indicating overbought conditions and potential bearish reversal zones. When the Smart Money Flow wave reaches or exceeds this level, it suggests strong buying pressure and institutional accumulation that may be exhausted. Standard range is 50-80. Higher values (70-80) identify only extreme overbought conditions. Lower values (50-60) provide earlier warnings of potential reversals or consolidation.'
tooltip_oversold = 'Lower threshold level indicating oversold conditions and potential bullish reversal zones. When the Smart Money Flow wave reaches or falls below this level, it suggests strong selling pressure and institutional distribution that may be exhausted. Standard range is -50 to -80. Lower values (-70 to -80) identify only extreme oversold conditions. Higher values (-50 to -60) provide earlier warnings of potential reversals or accumulation phases.'
tooltip_color_preset = 'Pre-configured color schemes optimized for different chart themes, visual preferences, and screen types. Each preset maintains strong contrast and clear visual separation for instant identification of bullish vs bearish money flow conditions.'
tooltip_bull_color = 'Color for bullish money flow periods (positive wave values). Represents conditions where institutional buying pressure, accumulation, and positive volume flow dominate. Typically shown in cool colors (cyan, green, blue) to indicate positive momentum, smart money inflows, and favorable risk conditions for long positions.'
tooltip_bear_color = 'Color for bearish money flow periods (negative wave values). Represents conditions where institutional selling pressure, distribution, and negative volume flow dominate. Typically shown in warm colors (red, orange, magenta) to indicate negative momentum, smart money outflows, and caution conditions suggesting risk-off positioning.'
tooltip_bar_coloring = 'Enable/disable coloring of main chart price bars based on the current Smart Money Flow direction and strength. When enabled, bars are tinted with a dynamic gradient color representing real-time institutional money flow intensity, providing immediate visual context of smart money activity directly on price action without switching between indicator panes.'
tooltip_smoothed_line = 'Enable/disable the display of an additional smoothed trend line overlaid on the main composite wave. This secondary line applies extra smoothing to help identify the underlying trend direction by filtering out short-term fluctuations and noise. Particularly useful for confirming trend strength, identifying divergences, and reducing false signals in choppy or ranging market conditions.'
 
source = input.source(hlc3, 'Price Source', group = calculation_settings, tooltip = tooltip_source)
momentum_channel_period = input.int(10, 'Momentum Channel Period', minval = 1, group = calculation_settings, tooltip = tooltip_momentum)
trend_period = input.int(21, 'Trend Period', minval = 1, group = calculation_settings, tooltip = tooltip_trend)
mfi_period = input.int(14, 'Money Flow Index Period', minval = 1, group = calculation_settings, tooltip = tooltip_mfi)
signal_smoothing = input.int(4, 'Signal Smoothing', minval = 1, group = calculation_settings, tooltip = tooltip_smoothing)
 
presetConfig = input.string('Default', 'Preconfigured Preset', options = ['Default', 'Fast Response', 'Smooth Trend'], group = calculation_settings, tooltip = tooltip_preset + '\n\n' + tooltip_preset_details)
 
if presetConfig == 'Fast Response'
    momentum_channel_period := 7
    trend_period := 14
    mfi_period := 10
    signal_smoothing := 2
else if presetConfig == 'Smooth Trend'
    momentum_channel_period := 14
    trend_period := 30
    mfi_period := 21
    signal_smoothing := 7
 
overbought_level = input.float(60, 'Overbought Level', minval = 20, maxval = 100, step = 5, group = calculation_settings, tooltip = tooltip_overbought)
oversold_level = input.float(-60, 'Oversold Level', minval = -100, maxval = -20, step = 5, group = calculation_settings, tooltip = tooltip_oversold)
 
colorPreset = input.string('Custom', 'Color Preset', options = ['Classic', 'Aqua', 'Cosmic', 'Ember', 'Neon', 'Custom'], group = visual_settings, tooltip = tooltip_color_preset)
bullColorInput = input.color(#00ffaa, 'Bullish Flow Color', group = visual_settings, tooltip = tooltip_bull_color)
bearColorInput = input.color(#ff0000, 'Bearish Flow Color', group = visual_settings, tooltip = tooltip_bear_color)
enable_bar_coloring = input.bool(true, 'Enable Bar Coloring', group = visual_settings, tooltip = tooltip_bar_coloring)
show_smoothed_line = input.bool(true, 'Show Smoothed Trend Line', group = visual_settings, tooltip = tooltip_smoothed_line)
 
[bullish_color, bearish_color] = switch colorPreset
    'Classic' => [#00ff00, #ff0000]
    'Aqua' => [#00bfff, #ff8c00]
    'Cosmic' => [#49ffce, #9932cc]
    'Ember' => [#ff6600, #00cccc]
    'Neon' => [#ffff00, #ff00ff]
    'Custom' => [bullColorInput, bearColorInput]
 
//              ╔════════════════════════════════╗              //
//              ║     SMART MONEY COMPONENTS     ║              //
//              ╚════════════════════════════════╝              //
 
// Money Flow Index (MFI)
raw_money_flow = source * volume
 
positive_flow = source >= source[1] ? raw_money_flow : 0
negative_flow = source < source[1] ? raw_money_flow : 0
 
positive_money_flow = math.sum(positive_flow, mfi_period)
negative_money_flow = math.sum(negative_flow, mfi_period)
money_flow_index = negative_money_flow != 0 ? 100 - 100 / (1 + positive_money_flow / negative_money_flow) : 100
 
// Chaikin Money Flow (CMF)
money_flow_multiplier = high != low ? (close - low - (high - close)) / (high - low) : 0
money_flow_volume = money_flow_multiplier * volume
volume_sma = ta.sma(volume, trend_period)
chaikin_money_flow = volume_sma != 0 ? ta.sma(money_flow_volume, trend_period) / volume_sma : 0
 
is_cmf_bullish = chaikin_money_flow > 0
is_cmf_bearish = chaikin_money_flow < 0
 
// Volume Analysis
volume_average = ta.sma(volume, trend_period)
volume_strength = volume_average != 0 ? volume / volume_average : 1
volume_weight = math.log(volume_strength + 1)
 
// Buy/Sell Pressure
buying_pressure = math.sum(volume * (close >= open ? 1 : 0), trend_period)
selling_pressure = math.sum(volume * (close < open ? 1 : 0), trend_period)
pressure_ratio = (buying_pressure + selling_pressure) != 0 ? (buying_pressure - selling_pressure) / (buying_pressure + selling_pressure) * 100 : 0
 
// Volume-Weighted Momentum
exponential_smooth_average = ta.ema(source, momentum_channel_period)
deviation = ta.ema(math.abs(source - exponential_smooth_average), momentum_channel_period)
channel_index = deviation != 0 ? (source - exponential_smooth_average) / (0.015 * deviation) * (1 + volume_weight * 0.5) : 0
 
// Composite Wave
momentum_wave = ta.ema(channel_index, trend_period)
money_flow_wave = (money_flow_index - 50) * 1.2
chaikin_flow_wave = chaikin_money_flow * 100
 
composite_wave = momentum_wave * 0.5 + chaikin_flow_wave * 0.3 + money_flow_wave * 0.2
smoothed_wave = ta.sma(composite_wave, signal_smoothing)
 
//              ╔════════════════════════════════╗              //
//              ║        SIGNAL DETECTION        ║              //
//              ╚════════════════════════════════╝              //
 
bullish_signal = ta.crossover(composite_wave, 0)
bearish_signal = ta.crossunder(composite_wave, 0)
 
extreme_overbought = composite_wave >= overbought_level
extreme_oversold = composite_wave <= oversold_level
 
overbought_reversal = extreme_overbought and ta.crossunder(composite_wave, overbought_level)
oversold_reversal = extreme_oversold and ta.crossover(composite_wave, oversold_level)
 
//              ╔════════════════════════════════╗              //
//              ║         VISUALIZATION          ║              //
//              ╚════════════════════════════════╝              //
 
wave_strength_percent = math.abs(composite_wave) / math.abs(overbought_level) * 100
volume_intensity_percent = math.min(volume_strength, 2.5) / 2.5 * 100
flow_alignment_percent = is_cmf_bullish and composite_wave > 0 or is_cmf_bearish and composite_wave < 0 ? 100 : 50
 
total_strength_percent = wave_strength_percent * 0.4 + volume_intensity_percent * 0.4 + flow_alignment_percent * 0.2
 
gradient_bullish_color = color.from_gradient(total_strength_percent, 0, 100, color.new(bullish_color, 85), color.new(bullish_color, 20))
gradient_bearish_color = color.from_gradient(total_strength_percent, 0, 100, color.new(bearish_color, 85), color.new(bearish_color, 20))
 
wave_fill_color = composite_wave > 0 ? gradient_bullish_color : gradient_bearish_color
wave_line_color = composite_wave > 0 ? color.new(bullish_color, 0) : color.new(bearish_color, 0)
 
zero_line_plot = plot(0, 'Zero', color = color.gray, linestyle = plot.linestyle_solid)
wave_plot = plot(composite_wave, title = 'Smart Money Flow', color = wave_line_color, linewidth = 3)
 
fill(wave_plot, zero_line_plot, color = wave_fill_color, title = 'Flow Gradient')
 
plot(show_smoothed_line ? smoothed_wave : na, title = 'Smoothed Trend', color = color.white, linewidth = 1)
 
plot(overbought_level, 'Overbought', color = color.gray, linestyle = plot.linestyle_dashed)
plot(oversold_level, 'Oversold', color = color.gray, linestyle = plot.linestyle_dashed)
 
bar_gradient_color = color.from_gradient(composite_wave, -70, 70, bearish_color, bullish_color)
barcolor(enable_bar_coloring ? bar_gradient_color : na, title = 'Money Flow Bar Color')
 
//              ╔════════════════════════════════╗              //
//              ║             ALERTS             ║              //
//              ╚════════════════════════════════╝              //
 
alertcondition(bullish_signal, title = 'Bullish Flow', message = 'Smart Money Flow: BULLISH crossover detected! Money flowing INTO {{exchange}}:{{ticker}} - {{interval}}')
alertcondition(bearish_signal, title = 'Bearish Flow', message = 'Smart Money Flow: BEARISH crossover detected! Money flowing OUT of {{exchange}}:{{ticker}} - {{interval}}')
alertcondition(bullish_signal or bearish_signal, title = 'Any Flow Direction Change', message = 'Smart Money Flow: Direction change detected! Check chart {{exchange}}:{{ticker}} - {{interval}}')
alertcondition(overbought_reversal, title = 'Overbought Reversal', message = 'Smart Money Flow: OVERBOUGHT reversal signal! Potential bearish reversal {{exchange}}:{{ticker}} - {{interval}}')
alertcondition(oversold_reversal, title = 'Oversold Reversal', message = 'Smart Money Flow: OVERSOLD reversal signal! Potential bullish reversal {{exchange}}:{{ticker}} - {{interval}}')
alertcondition(extreme_overbought, title = 'Extreme Overbought', message = 'Smart Money Flow: EXTREME overbought conditions! {{exchange}}:{{ticker}} - {{interval}}')
alertcondition(extreme_oversold, title = 'Extreme Oversold', message = 'Smart Money Flow: EXTREME oversold conditions! {{exchange}}:{{ticker}} - {{interval}}')

← 返回列表