OPEN-SOURCE SCRIPT
六脉齐发多空策略

六脉齐发多空策略
# Six Meridians Unified Long/Short Strategy
## Overview
The "Six Meridians Unified Long/Short Strategy" is a comprehensive quantitative trading strategy built on TradingView Pine Script v6, designed for cross-asset long/short trading (stocks, cryptocurrencies, futures, forex, etc.). It leverages the resonance of **6 classic technical indicators** to filter high-confidence trading signals, reducing false signals caused by single-indicator bias and improving the reliability of entry/exit decisions.
## Core Indicators (6 "Meridians")
The strategy evaluates bullish/bearish trends by calculating 6 key technical indicators, with a "bullish count" system to quantify trend strength:
| Indicator | Calculation Parameters | Bullish Condition | Bearish Condition |
|-------------------------|------------------------------|--------------------------------------------|--------------------------------------------|
| MACD | Fast=12, Slow=26, Signal=9 | MACD line crosses above Signal line | MACD line crosses below Signal line |
| KDJ (Stochastic Oscillator) | Length=14, SmoothK=3, SmoothD=3 | K line > D line | K line < D line |
| RSI (Relative Strength Index) | Short=6, Long=12 | Short-period RSI (6) > Long-period RSI (12) | Short-period RSI (6) < Long-period RSI (12) |
| LWR (Modified Williams %R) | Length=14, Smooth=6 | LWR1 (WMA-smooth) > LWR2 (6-period WMA) | LWR1 < LWR2 |
| BBI (Bollinger Band Index) | EMA(3)+EMA(6)+EMA(12)+EMA(24) /4 | Close price > BBI line | Close price < BBI line |
| MTM (Momentum) | Period=12, MMS=6, MMM=14 | Short momentum line (MMS) > Long momentum line (MMM) | Short momentum line (MMS) < Long momentum line (MMM) |
## Trading Logic
The strategy uses a "count-based" trigger mechanism to execute position management (no pyramiding allowed):
### Long Position Rules
1. **Entry**: Open long position only when all 6 indicators show bullish signals (`bullCount = 6`).
2. **Partial Exit**: Reduce 50% of long position when 4 indicators remain bullish (`bullCount = 4`).
3. **Full Exit**: Close all long positions when ≤3 indicators are bullish (`bullCount ≤ 3`).
### Short Position Rules
1. **Entry**: Open short position only when all 6 indicators show bearish signals (`bearCount = 6`).
2. **Partial Exit**: Cover 50% of short position when 4 indicators remain bearish (`bearCount = 4`).
3. **Full Exit**: Close all short positions when ≤3 indicators are bearish (`bearCount ≤ 3`).
## Strategy Parameters (Risk & Capital Management)
| Parameter | Value | Description |
|--------------------------|----------------|----------------------------------------------|
| Initial Capital | $100,000 | Starting equity for backtesting |
| Default Order Size | $10,000 (cash) | Fixed cash amount per trade (instead of lots) |
| Commission | 0.1% per trade | Realistic transaction cost (percent-based) |
| Margin Requirement | 100% | No leverage (1:1 trading) |
| Pyramiding | 0 | No additional positions on existing trades |
## Key Features
1. **Multi-Indicator Resonance**: Eliminates noise from single-indicator false signals by requiring consensus across 6 diverse technical metrics.
2. **Gradual Position Management**: Partial exit (50%) before full closure to lock in profits and reduce downside risk.
3. **Full Automation**: Automatically executes entry/exit/position adjustment without manual intervention.
4. **Visualization Tools**: Plots BBI line, long/short signal labels, and bullish indicator count for easy strategy monitoring.
5. **Versatility**: Adaptable to multiple timeframes (15min, 1H, 4H, daily) and asset classes.
## Notes
- The strategy is optimized for trend-following markets and may underperform in choppy/range-bound conditions.
- Backtest results should be validated across different market cycles (bull, bear, sideways) before live trading.
- Parameters (e.g., indicator periods, order size) can be adjusted based on specific asset volatility and trading style.
# Six Meridians Unified Long/Short Strategy
## Overview
The "Six Meridians Unified Long/Short Strategy" is a comprehensive quantitative trading strategy built on TradingView Pine Script v6, designed for cross-asset long/short trading (stocks, cryptocurrencies, futures, forex, etc.). It leverages the resonance of **6 classic technical indicators** to filter high-confidence trading signals, reducing false signals caused by single-indicator bias and improving the reliability of entry/exit decisions.
## Core Indicators (6 "Meridians")
The strategy evaluates bullish/bearish trends by calculating 6 key technical indicators, with a "bullish count" system to quantify trend strength:
| Indicator | Calculation Parameters | Bullish Condition | Bearish Condition |
|-------------------------|------------------------------|--------------------------------------------|--------------------------------------------|
| MACD | Fast=12, Slow=26, Signal=9 | MACD line crosses above Signal line | MACD line crosses below Signal line |
| KDJ (Stochastic Oscillator) | Length=14, SmoothK=3, SmoothD=3 | K line > D line | K line < D line |
| RSI (Relative Strength Index) | Short=6, Long=12 | Short-period RSI (6) > Long-period RSI (12) | Short-period RSI (6) < Long-period RSI (12) |
| LWR (Modified Williams %R) | Length=14, Smooth=6 | LWR1 (WMA-smooth) > LWR2 (6-period WMA) | LWR1 < LWR2 |
| BBI (Bollinger Band Index) | EMA(3)+EMA(6)+EMA(12)+EMA(24) /4 | Close price > BBI line | Close price < BBI line |
| MTM (Momentum) | Period=12, MMS=6, MMM=14 | Short momentum line (MMS) > Long momentum line (MMM) | Short momentum line (MMS) < Long momentum line (MMM) |
## Trading Logic
The strategy uses a "count-based" trigger mechanism to execute position management (no pyramiding allowed):
### Long Position Rules
1. **Entry**: Open long position only when all 6 indicators show bullish signals (`bullCount = 6`).
2. **Partial Exit**: Reduce 50% of long position when 4 indicators remain bullish (`bullCount = 4`).
3. **Full Exit**: Close all long positions when ≤3 indicators are bullish (`bullCount ≤ 3`).
### Short Position Rules
1. **Entry**: Open short position only when all 6 indicators show bearish signals (`bearCount = 6`).
2. **Partial Exit**: Cover 50% of short position when 4 indicators remain bearish (`bearCount = 4`).
3. **Full Exit**: Close all short positions when ≤3 indicators are bearish (`bearCount ≤ 3`).
## Strategy Parameters (Risk & Capital Management)
| Parameter | Value | Description |
|--------------------------|----------------|----------------------------------------------|
| Initial Capital | $100,000 | Starting equity for backtesting |
| Default Order Size | $10,000 (cash) | Fixed cash amount per trade (instead of lots) |
| Commission | 0.1% per trade | Realistic transaction cost (percent-based) |
| Margin Requirement | 100% | No leverage (1:1 trading) |
| Pyramiding | 0 | No additional positions on existing trades |
## Key Features
1. **Multi-Indicator Resonance**: Eliminates noise from single-indicator false signals by requiring consensus across 6 diverse technical metrics.
2. **Gradual Position Management**: Partial exit (50%) before full closure to lock in profits and reduce downside risk.
3. **Full Automation**: Automatically executes entry/exit/position adjustment without manual intervention.
4. **Visualization Tools**: Plots BBI line, long/short signal labels, and bullish indicator count for easy strategy monitoring.
5. **Versatility**: Adaptable to multiple timeframes (15min, 1H, 4H, daily) and asset classes.
## Notes
- The strategy is optimized for trend-following markets and may underperform in choppy/range-bound conditions.
- Backtest results should be validated across different market cycles (bull, bear, sideways) before live trading.
- Parameters (e.g., indicator periods, order size) can be adjusted based on specific asset volatility and trading style.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.