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提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。