Chan Theory - Chanlun Ultra

Overview
This script is based on the core technical framework of Chan Theory, transforming complex market fluctuations into a multi-layered, quantifiable structural analysis system. Through real-time dynamic computation, it automatically parses key components in price movements such as fractals, pens, segments, and pivot zones. Integrated with momentum analysis and trading signal alerts, it provides traders with comprehensive market insights from micro to macro perspectives. The core distinction of Chan Theory from traditional technical indicators lies in its rigorous recursive logic and human-centric market philosophy. This script faithfully restores Chan Theory's essence of "using Zen to resolve market complexity," decomposing spiral price movements into an orderly trading decision system.
Technical Principles
This indicator implements the complete recognition process from candlesticks to fractals, pens, segments, and pivot zones using pure Pine Script under Chan Theory's framework. Core technical implementations include:
1. Candlestick Containment Processing
Employs specific algorithms to handle candlestick containment relationships, eliminating random noise:
In uptrends: Select the higher high and higher low values
In downtrends: Select the lower high and lower low values
Ensure complete elimination of containment through recursive processing
2. Fractal Identification System
Performs strict fractal judgment on processed candlesticks:
Top Fractal: The middle candlestick's high is higher than both adjacent candlesticks
Bottom Fractal: The middle candlestick's low is lower than both adjacent candlesticks
Validate fractal effectiveness via the filterOperateType function
3. Pen Construction Mechanism & Type Selection
Connects valid top/bottom fractals to form pen structures, offering four pen types:
Classic Pen: Traditional Chan Theory definition, strictly following classic rules
Optimized Pen: Enhanced algorithm for short-term volatility recognition
4K Pen: Builds pens based on fractals formed by at least 4 candlesticks (improves stability)
Strict Pen: Employs the most stringent validation conditions for reliability
4. Segment Partitioning Algorithm
Applies segment rules to pen sequences with three modes:
- Dynamic Real-time Progressive Correction: Adjusts forming segments continuously with new data
- Strict Mode: Fully complies with Chan Theory definitions
- Extension Mode: Flexible handling of trend developments
5. Pivot Zone Recognition Technology
Identifies pen-level and segment-level pivot zones
Calculates pivot zone price ranges and time durations
Analyzes pivot zone evolution characteristics
Supports display of pivot zones across different levels
Trading Signal System & Filters
Trading Signal Filtering System
This indicator provides comprehensive filtering functions:
Fractal Validity Filter: Verifies fractal patterns and post-fractal developments
Basic Fractal Filter: Eliminates non-compliant fractals through basic feature checks
Type I MACD Divergence Filter: Enhances Type I signal reliability via MACD divergence analysis
Type II Signal Filter: Custom conditions for Type II signals
-False Signal Trap Avoidance: Detects and bypasses deceptive price patterns
Chan Theory Trading Signal Principles
Type I Signals (Trend Reversals)
Principle: Forms when price makes new highs/lows with weakening internal momentum (divergence)
Identification: Compares structural features of adjacent same-direction pens
Application: Early trend reversal signals for swing trading
Type II Signals (Pullback Entries)
Principle: Occurs during retracements as sub-level reversal signals
Identification: Determined by pivot zone support/resistance and fractal combinations
Application: Optimal positions for pullback trades with controlled risk
Type III Signals (Breakout Confirmations)
Principle: Confirms pivot zone breakouts
Identification: Price breaks prior pivot zone boundaries with valid fractals
Application: Trend continuation signals for trend-following strategies
Indicator Features
Multi-Level Structural Analysis
Distinguishes structures across levels via level parameters
Higher-level trends guide lower-level operations
Implements cross-level collaborative logic
Displays sub-level pivot zones
Structural Visualization
Pens: Displayed per selected pen type
Segments: Rendered according to chosen segment mode
Pivot Zones: Color gradients indicate consolidation strength
Technical Implementation
Data Structure Design
Pen Object: Stores direction, timestamps, and price attributes
Segment Object: Manages segments and constituent pens
Pivot Object: Defines pivot zone ranges and characteristics
Grade Object: Organizes analysis results across levels
User Guide
Parameter Settings
Pen Type: Classic/Optimized/4K/Strict (adapt to analysis needs)
Segment Mode: Dynamic/Strict/Extension (match trading strategies)
Signal Filters: Enable/disable specific filters
Pivot Display: Toggle sub-level pivot zones
Divergence Settings: Configure types (regular/hidden) and display styles
Strategy Settings: Set trading rules linked to signals
Strategy Configuration
Follow Segments: Trade in alignment with segment direction
Signal Participation: Enable/disable Type I/II/III signals
Signal Conditions: Require signals to appear post-pivot zone formation
Prevent Early Entries:
Type I signals require ≥1 pivot zone or 5 pens
Type II Safety Control: Participate only if Type III signals are absent
Practical Recommendations
Select pen types/segment modes per market conditions
Adjust filters for different instruments and timeframes
Enhance accuracy through multi-level analysis
Confirm Type I signals with divergence indicators
Choose strategy parameters aligned with risk tolerance
Value Proposition
Systematizes Chan Theory into computable structures
Multiple pen/segment methods adapt to diverse markets
Advanced filtering significantly improves signal quality (historically validated)
Multi-level analysis provides holistic market insights
This tool is for technical analysis only. It does not constitute investment advice. Users must exercise independent judgment based on personal risk tolerance and objectives.
概述
本脚本基于缠论核心技术框架,将复杂的市场波动转化为多层次、可量化的结构分析系统。通过实时动态演算,自动解析价格走势中的分型、笔、线段、中枢等核心组件,并融合动量分析与交易信号预警功能,为交易者提供从微观到宏观的全方位市场透视。缠论区别于传统技术指标的核心在于其严格的递归逻辑与人性化市场哲学,本脚本忠实还原缠论"以禅破缠"的思想精髓,将螺旋缠绕的价格运动分解为有序的交易决策体系。
技术原理
本指标基于缠论技术分析框架,通过纯Pine Script实现了从K线到分型、笔、线段和中枢的完整识别流程。核心技术实现包括:
1. K线包含处理
采用特定算法处理K线包含关系,消除随机波动干扰:
- 上涨趋势中取高点高值、低点高值
- 下跌趋势中取高点低值、低点低值
- 通过递归处理确保包含关系完全消除
2. 分型识别系统
在处理后的K线基础上实现严格的分型判断:
- 顶分型:中间K线高点高于两侧K线
- 底分型:中间K线低点低于两侧K线
- 通过`filterOperateType`函数实现分型有效性验证
3. 笔的构建机制与类型选择
连接有效顶底分型形成笔结构,提供四种笔类型选择:
- **老笔**:传统缠论笔定义,严格遵循经典规则
- **新笔**:优化算法,增强对短期波动的识别能力
- **4K**:基于至少4根K线形成的分型构建笔,提高稳定性
- **严笔**:采用最严格的条件验证,确保形成的笔结构可靠
4. 线段划分算法
基于笔序列应用线段划分规则,支持三种线段模式:
- **当下延伸后修正**:实时计算当前形成中的线段,并随新数据更新修正
- **严格模式**:要求线段完全符合缠论定义,减少假信号
- **延伸模式**:更灵活地处理线段延伸情况,适合趋势分析
5. 中枢识别技术
- 实现笔中枢和线段中枢识别
- 计算中枢价格区间与时间范围
- 分析中枢演变特征
- 支持显示不同级别中枢功能
买卖点系统与过滤机制
买卖点过滤系统
本指标提供全面的买卖点过滤功能:
- **买卖点分型过滤**:检验分型形态有效性,验证分型后续发展
- **买卖点分型基础过滤**:针对分型基本特征进行验证,排除不合格分型
- **1买卖macd背驰过滤**:通过MACD判断背驰情况,提高一类买卖点可靠性
- **2买卖点过滤**:专门针对二类买卖点的过滤条件
- **防狼术**:避免陷阱式买卖点,提高交易安全性
缠论买卖点原理
1. **一类买卖点**
- 原理:基于趋势背驰原理,当价格创新高/低但内部结构力度减弱时形成
- 识别方法:通过比较相邻同向笔的结构特征判断力度变化
- 应用:提供趋势可能反转的早期信号,适合波段操作
2. **二类买卖点**
- 原理:发生在回调过程中,属于次级别转折信号
- 识别方法:通过中枢支撑位与分型组合判断
- 应用:回调买入或做空的较佳位置,风险相对可控
3. **三类买卖点**
- 原理:中枢突破确认信号
- 识别方法:价格突破前中枢边界并形成有效分型
- 应用:趋势延续的确认信号,适合追踪趋势
指标特点
多级别结构分析
本指标支持多级别联动分析:
- 通过级别参数区分不同级别结构
- 高级别趋势指导低级别操作
- 实现级别间的协同判断逻辑
- 支持显示次级别中枢功能
结构可视化
- 笔结构:根据选择的笔类型显示
- 线段结构:按照选定的线段模式呈现
- 中枢区域:颜色渐变标识不同强度
技术实现说明
数据结构设计
指标设计了完整的面向对象结构:
- Pen结构:存储笔的方向、时间、价格等属性
- Segment结构:管理线段及其组成笔
- Pivot结构:表示中枢范围和特性
- Grade结构:区分不同级别的分析结果
使用指南
参数设置
- 笔的类型:选择老笔、新笔、4K或严笔以适应不同分析需求
- 线段模式:根据交易策略选择合适的线段计算方式
- 买卖点过滤:根据需要启用不同的过滤机制
- 中枢显示:选择是否显示次级别中枢
- 背离设置:选择背离类型、显示方式和样式
- 策略设置:配置与买卖点相关的交易策略选项
策略应用配置
- 跟随线段:根据线段方向进行交易
- 买卖点参与设置:可选择性参与一类、二类和三类买卖点
- 买卖点条件限制:可设置买卖点需要在中枢形成后出现
- 防止过早进场:可要求一类买卖点至少出现一个中枢后或至少5笔后才参与
- 二类买卖点安全性控制:可选择仅在未出现三类买卖点的情况下参与
实际应用建议
- 结合市场环境选择合适的笔类型和线段模式
- 针对不同品种和时间周期调整过滤设置
- 通过多级别分析提高判断准确性
- 使用背离指标确认一类买卖点的有效性
- 根据策略风格选择适合的策略配置参数
技术特点与价值
本指标通过系统化实现缠论结构分析,提供了一种客观的技术分析工具。它的核心价值在于:
1. 将复杂的缠论理论系统化为可计算的结构
2. 提供多种笔、线段判断方法以适应不同市场环境
3. 完善的买卖点过滤系统大幅提高信号质量
4. 多级别联动分析提供全面市场视角
*本指标仅提供技术分析参考,不构成投资建议。用户应根据自身风险承受能力和投资目标进行判断。*
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi riyue secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.
Penafian
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi riyue secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.