OPEN-SOURCE SCRIPT

Commodity Pulse Matrix (CPM) [WavesUnchained] [Strategy]

223
Commodity Pulse Matrix (CPM) - Strategy Version

⚠️ Development Status

ACTIVE DEVELOPMENT - This strategy is currently under heavy development and optimization. The risk management settings, entry/exit logic, and parameter tuning are still being refined and are NOT yet satisfactory for live trading.

Current development areas:

  • Stop-loss and take-profit optimization
  • Position sizing and risk management
  • Entry timing and signal filtering
  • Backtest validation across different market conditions


⚠️ Use for testing and backtesting only - NOT recommended for live trading yet!

For detailed information about the underlying indicator logic, signals, and analysis methods, please refer to the Commodity Pulse Matrix (CPM) indicator description.

Overview

The CPM Strategy is an automated trading system based on the Commodity Pulse Matrix indicator. It converts the indicator's multi-timeframe confluence signals into executable trades with dynamic ATR-based risk management.

Strategy Core Features

Signal Sources

The strategy trades based on:

  • Strong Buy/Sell signals from the CPM indicator
  • Multi-timeframe alignment (configurable: 3/3, 2/3, or score-only)
  • EMA-200 trend filter (prevents counter-trend entries)
  • Dynamic signal cooldown (5-8 bars)
  • Optional reversal zone signals (triple-confirmed)


Risk Management (ATR-Based)

Stop-Loss & Take-Profit

  • Stop-Loss: 2.5x ATR (default) - Dynamic distance based on volatility
  • Take-Profit: 4.0x ATR (default) - Risk/Reward ratio of 1.6:1
  • ATR Length: 14 periods (adjustable)
  • Both SL and TP adjust to current market volatility


Trailing Stop (Optional)

  • Enabled by default
  • Trails at 2.5x ATR distance
  • Protects profits in trending moves
  • Can be disabled for fixed SL/TP only


Position Management

Trade Direction Filter

  • Both Directions (default) - Trade both Long and Short
  • Long Only - Only enter long positions
  • Short Only - Only enter short positions


Cooldown After Exit

  • Default: 3 bars minimum after closing a position
  • Prevents immediate re-entry (whipsaw protection)
  • Adjustable from 0 (disabled) to any number of bars


Signal Filtering

Signal Mode (Timeframe Consensus)

  • Strict (3/3 TFs): All 3 timeframes must agree - Most conservative
  • Majority (2/3 TFs): At least 2 of 3 timeframes agree - Balanced (default)
  • Flexible (Score Only): Overall score threshold only - Most signals


Optional Filters

  • Min ABS(overallScore): Only trade when confluence score meets minimum (default: 0 = disabled)
  • Confirmed Bar Only: Wait for bar close before entry (prevents repainting) - Recommended ON


Strategy Settings Guide

For Conservative Trading (Lower Risk)

  • Signal Mode: "Strict (3/3 TFs)"
  • Stop-Loss: 3.0x ATR or higher
  • Take-Profit: 5.0x ATR or higher
  • Trailing Stop: Enabled
  • Cooldown: 5-10 bars
  • Min Score: 8.0 or higher


For Aggressive Trading (More Signals)

  • Signal Mode: "Flexible (Score Only)"
  • Stop-Loss: 2.0x ATR
  • Take-Profit: 3.0x ATR
  • Trailing Stop: Optional
  • Cooldown: 0-3 bars
  • Min Score: 4.0 or disabled


For Balanced Trading (Recommended Starting Point)

  • Signal Mode: "Majority (2/3 TFs)"
  • Stop-Loss: 2.5x ATR
  • Take-Profit: 4.0x ATR
  • Trailing Stop: Enabled
  • Cooldown: 3 bars
  • Min Score: 6.0-8.0


TradingView Strategy Tester Settings

Essential Settings to Configure:

Properties Tab

  • Initial Capital: Set to realistic account size
  • Order Size: Use "% of Equity" (e.g., 10-25% per trade)
  • Commission: Set realistic commission (e.g., 0.05% for crypto, 0.1% for stocks)
  • Slippage: Add realistic slippage (1-3 ticks for liquid markets)
  • Verify "Recalculate: On Every Tick" is DISABLED (for realistic backtests)


Inputs Tab

  • Adjust ATR multipliers for your market
  • Set appropriate cooldown period
  • Choose signal mode based on desired trade frequency
  • Enable/disable trailing stop
  • Configure directional filter if needed


Backtesting Recommendations

Before Using This Strategy:

  1. Test across multiple markets - What works for one commodity may not work for another
  2. Test different timeframes - Strategy behavior changes significantly with TF
  3. Test different market conditions - Trending vs ranging markets
  4. Validate performance metrics - Win rate, profit factor, max drawdown, Sharpe ratio
  5. Forward test on paper account - Before risking real capital


Key Metrics to Monitor:

  • Win Rate (aim for >40% minimum)
  • Profit Factor (aim for >1.5)
  • Max Drawdown (should be acceptable for your risk tolerance)
  • Sharpe Ratio (higher is better, >1.0 is good)
  • Average Trade (should be positive after commissions/slippage)


Known Limitations

  • Range-bound markets: May produce more whipsaws despite filters
  • Low volatility: ATR-based stops may be too tight
  • High volatility: ATR-based stops may be too wide
  • News events: Strategy cannot account for fundamental shocks
  • Signal timing: Entry timing is still being optimized


Indicator vs Strategy

When to use the Indicator:
- Manual trading with discretion
- Confluence analysis and timing
- Multiple signal validation
- Learning market structure

When to use the Strategy:
- Automated backtesting
- System validation
- Parameter optimization
- Performance measurement

⚠️ The indicator provides richer information and context than the strategy can execute!

Technical Details

Pine Script v6
Non-repainting: Uses confirmed bars for HTF data
Strategy type: Long/Short with dynamic stops
Risk management: ATR-based (adaptive to volatility)
Position sizing: Configured in Strategy Tester
Pyramiding: Default 1 (no adding to positions)

Important Notes

⚠️ Strategy parameters are still under optimization - Current settings may not be optimal for all markets or timeframes

⚠️ Backtest thoroughly before live trading - Test across different market conditions and timeframes

⚠️ Risk management is critical - Use appropriate position sizing (1-2% risk per trade recommended)

⚠️ Market conditions change - A strategy that works in trending markets may fail in ranging markets

⚠️ Commission and slippage matter - Always include realistic costs in backtests

✅ Start with conservative settings and optimize gradually
✅ Paper trade before going live
✅ Monitor performance and adjust as needed
✅ Never risk more than you can afford to lose

Disclaimer

Educational and testing purposes only. Not financial advice.

This strategy is provided as-is for backtesting and educational purposes. Past performance is not indicative of future results. Trading involves substantial risk of loss. The developer is not responsible for any losses incurred from using this strategy. Always do your own research, backtest thoroughly, and consult with a qualified financial advisor before making trading decisions.

NEVER use this strategy with real money until:
  1. You have thoroughly backtested it on your specific market and timeframe
  2. You understand all parameters and their impact
  3. You have forward tested it on a paper account
  4. You are comfortable with the maximum drawdown and risk profile
  5. The strategy has been marked as production-ready by the developer


Version

v1.2 - Strategy Adapter (Active Development)
Based on: Commodity Pulse Matrix v1.2 Indicator
Last Updated: 2025-10-10

For detailed indicator documentation, see the Commodity Pulse Matrix (CPM) indicator description.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.