OPEN-SOURCE SCRIPT
已更新 KCandle Strategy 1.0

# KCandle Strategy 1.0 - Trading Strategy Description
## Overview
The **KCandle Strategy** is an advanced Pine Script trading system based on bullish and bearish engulfing candlestick patterns, enhanced with sophisticated risk management and position optimization features.
## Core Logic
### Entry Signal Generation
- **Pattern Recognition**: Detects bullish and bearish engulfing candlestick formations
- **EMA Filter**: Uses a customizable EMA (default 25) to filter trades in the direction of the trend
- **Entry Levels**:
- **Long entries** at 25% of the candlestick range from the low
- **Short entries** at 75% of the candlestick range from the low
- **Signal Validation**: Orange candlesticks indicate valid setup conditions
### Risk Management System
#### 1. **Stop Loss & Take Profit**
- Configurable stop loss in pips
- Risk-reward ratio setting (default 2:1)
- Visual representation with colored lines and labels
#### 2. **Break-Even Management**
- Automatically moves stop loss to break-even when specified R:R is reached
- Customizable break-even offset for added protection
- Prevents losing trades after reaching profitability
#### 3. **Trailing Stop System**
- **Activation Trigger**: Activates when position reaches specified R:R level
- **Distance Control**: Maintains trailing stop at defined distance from entry
- **Step Management**: Moves stop loss forward in incremental R steps
- **Dynamic Protection**: Locks in profits while allowing for continued upside
### Advanced Features
#### Position Management
- **Pyramiding Support**: Optional multiple position entries with size reduction
- **Order Expiration**: Pending orders automatically cancel after specified bars
- **Position Sizing**: Percentage-based allocation with pyramid level adjustments
#### Visual Interface
- **Real-time Monitoring**: Comprehensive information panel with all strategy metrics
- **Historical Tracking**: Visual representation of past trades and levels
- **Color-coded Indicators**: Different colors for break-even, trailing, and standard stops
- **Debug Options**: Optional labels for troubleshooting and optimization
## Key Parameters
### Basic Settings
- **EMA Length**: Trend filter period
- **Stop Loss**: Risk per trade in pips
- **Risk/Reward**: Target profit ratio
- **Order Validity**: Duration of pending orders
### Risk Management
- **Break-Even R:R**: Profit level to trigger break-even
- **Trailing Activation**: R:R level to start trailing
- **Trailing Distance**: Stop distance from entry when trailing
- **Trailing Step**: Increment for stop loss advancement
## Strategy Benefits
1. **Objective Entry Signals**: Based on proven candlestick patterns
2. **Trend Alignment**: EMA filter ensures trades align with market direction
3. **Robust Risk Control**: Multiple layers of protection (SL, BE, Trailing)
4. **Profit Optimization**: Trailing stops maximize winning trade potential
5. **Flexibility**: Extensive customization options for different market conditions
6. **Visual Clarity**: Complete visual feedback for trade management
## Ideal Use Cases
- **Swing Trading**: Medium-term positions with trend-following approach
- **Breakout Trading**: Capturing momentum from engulfing patterns
- **Risk-Conscious Trading**: Suitable for traders prioritizing capital preservation
- **Multi-Timeframe**: Adaptable to various timeframes and instruments
---
*The KCandle Strategy combines traditional technical analysis with modern risk management techniques, providing traders with a comprehensive tool for systematic market participation.*
## Overview
The **KCandle Strategy** is an advanced Pine Script trading system based on bullish and bearish engulfing candlestick patterns, enhanced with sophisticated risk management and position optimization features.
## Core Logic
### Entry Signal Generation
- **Pattern Recognition**: Detects bullish and bearish engulfing candlestick formations
- **EMA Filter**: Uses a customizable EMA (default 25) to filter trades in the direction of the trend
- **Entry Levels**:
- **Long entries** at 25% of the candlestick range from the low
- **Short entries** at 75% of the candlestick range from the low
- **Signal Validation**: Orange candlesticks indicate valid setup conditions
### Risk Management System
#### 1. **Stop Loss & Take Profit**
- Configurable stop loss in pips
- Risk-reward ratio setting (default 2:1)
- Visual representation with colored lines and labels
#### 2. **Break-Even Management**
- Automatically moves stop loss to break-even when specified R:R is reached
- Customizable break-even offset for added protection
- Prevents losing trades after reaching profitability
#### 3. **Trailing Stop System**
- **Activation Trigger**: Activates when position reaches specified R:R level
- **Distance Control**: Maintains trailing stop at defined distance from entry
- **Step Management**: Moves stop loss forward in incremental R steps
- **Dynamic Protection**: Locks in profits while allowing for continued upside
### Advanced Features
#### Position Management
- **Pyramiding Support**: Optional multiple position entries with size reduction
- **Order Expiration**: Pending orders automatically cancel after specified bars
- **Position Sizing**: Percentage-based allocation with pyramid level adjustments
#### Visual Interface
- **Real-time Monitoring**: Comprehensive information panel with all strategy metrics
- **Historical Tracking**: Visual representation of past trades and levels
- **Color-coded Indicators**: Different colors for break-even, trailing, and standard stops
- **Debug Options**: Optional labels for troubleshooting and optimization
## Key Parameters
### Basic Settings
- **EMA Length**: Trend filter period
- **Stop Loss**: Risk per trade in pips
- **Risk/Reward**: Target profit ratio
- **Order Validity**: Duration of pending orders
### Risk Management
- **Break-Even R:R**: Profit level to trigger break-even
- **Trailing Activation**: R:R level to start trailing
- **Trailing Distance**: Stop distance from entry when trailing
- **Trailing Step**: Increment for stop loss advancement
## Strategy Benefits
1. **Objective Entry Signals**: Based on proven candlestick patterns
2. **Trend Alignment**: EMA filter ensures trades align with market direction
3. **Robust Risk Control**: Multiple layers of protection (SL, BE, Trailing)
4. **Profit Optimization**: Trailing stops maximize winning trade potential
5. **Flexibility**: Extensive customization options for different market conditions
6. **Visual Clarity**: Complete visual feedback for trade management
## Ideal Use Cases
- **Swing Trading**: Medium-term positions with trend-following approach
- **Breakout Trading**: Capturing momentum from engulfing patterns
- **Risk-Conscious Trading**: Suitable for traders prioritizing capital preservation
- **Multi-Timeframe**: Adaptable to various timeframes and instruments
---
*The KCandle Strategy combines traditional technical analysis with modern risk management techniques, providing traders with a comprehensive tool for systematic market participation.*
版本注释
-Bug fix开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。