OPEN-SOURCE SCRIPT
更新済

[LTS] Marubozu Candle Strategy

147
OVERVIEW
The Marubozu Candle Strategy identifies and trades wickless candles (Marubozu patterns) with dynamic take-profit and stop-loss levels based on market volatility. This indicator combines traditional Japanese candlestick pattern recognition with modern volatility-adjusted risk management and includes a comprehensive performance tracking dashboard.

A Marubozu candle is a powerful continuation pattern characterized by the complete absence of wicks on one side, indicating strong directional momentum. This strategy specifically detects:
- Bullish Marubozu: Close > Open AND Low = Open (no lower wick)
- Bearish Marubozu: Close < Open AND High = Open (no upper wick)

When price returns to test these levels, the indicator generates trading signals with predefined risk-reward parameters.


CORE METHODOLOGY
Detection Logic:
The script scans each bar for Marubozu formations using precise price comparisons. When a wickless candle appears, a horizontal line extends from the opening price, marking it as a potential support (bullish) or resistance (bearish) level. These levels remain active until price touches them or until the maximum line limit is reached.

EMA Filter (Optional):
An exponential moving average filter enhances signal quality by requiring proper trend alignment. For bullish signals, price must be above the EMA when touching the level. For bearish signals, price must be below the EMA. This filter reduces counter-trend trades and improves win rates in trending markets. Users can disable this filter for range-bound conditions.

Dynamic Risk Management:
The strategy employs ATR-based (Average True Range) position sizing rather than fixed point values. This approach adapts to market volatility automatically:
- In low volatility: Tighter stops and targets
- In high volatility: Wider stops and targets proportional to market movement

Default settings use a 2:1 reward-to-risk ratio (1x ATR for take-profit, 0.5x ATR for stop-loss), but users can adjust these multipliers to match their trading style.


HOW IT WORKS
Step 1 - Pattern Detection:
On each bar, the indicator evaluates whether the candle qualifies as a Marubozu by comparing the high, low, open, and close prices. When detected, the opening price becomes the key level.

Step 2 - Level Management:
Horizontal lines extend from each Marubozu's opening price. The indicator maintains two separate arrays: one for unbroken levels (actively extending) and one for broken levels (historical reference). Users can configure how many of each type to display, preventing chart clutter while maintaining relevant context.

Step 3 - Signal Generation:
When price returns to touch a Marubozu level, the indicator evaluates the EMA filter condition. If the filter passes (or is disabled), the script draws TP/SL boxes showing the expected profit and loss zones based on current ATR values.

Step 4 - Trade Tracking:
Each valid signal enters the tracking system, which monitors subsequent price action to determine outcomes. The script identifies whether the take-profit or stop-loss was hit first (discarding trades where both trigger on the same candle to avoid ambiguous results).


PERFORMANCE DASHBOARD
The integrated dashboard provides real-time strategy analytics to automatically convert results to dollar values for any instrument:

Tracked Metrics:
- Total Trades: Complete count of closed positions
- Wins/Losses: Individual counts with color coding
- Win Rate: Success percentage with dynamic color (green >= 50%, red < 50%)
- Total P&L: Cumulative profit/loss in dollars
- Avg Win: Mean dollar amount per winning trade
- Avg Loss: Mean dollar amount per losing trade
NOTE: The dollar values shown in the dashboard are for trading only a single share/contract/etc. You will need to manually multiply those numbers by the amount of shares/contracts you are trading to get a true value.

The dollar conversion works automatically across all markets:
- Futures contracts (ES, NQ, CL, etc.) use their contract specifications
- Forex pairs use standard lot calculations
- Stocks and crypto use their respective point values

This eliminates manual calculation and provides immediate performance feedback in meaningful currency terms.


CUSTOMIZATION OPTIONS
ATR Settings:
- ATR Period: Lookback length for volatility calculation (default: 14)
- TP Multiplier: Take-profit distance as multiple of ATR (default: 3.0)
- SL Multiplier: Stop-loss distance as multiple of ATR (default: 1.5)

EMA Settings:
- EMA Length: Period for trend filter calculation (default: 9)
- Use EMA Filter: Toggle trend confirmation requirement (default: enabled)

Visual Settings:
- Bullish Color: Color for long signals and wins (default: green)
- Bearish Color: Color for short signals and losses (default: red)
- EMA Color: Color for trend filter line (default: orange)
- Line Width: Thickness of Marubozu level lines (1-5, default: 2)
- EMA Width: Thickness of EMA line (1-5, default: 2)

Line Management:
- Max Unbroken Lines: Limit for active extending lines (default: 10)
- Max Broken Lines: Limit for historical touched lines (default: 5)

Dashboard Settings:
- Show Dashboard: Toggle performance display on/off
- Dashboard Position: Corner placement (4 options)
- Dashboard Size: Text size selection (Tiny/Small/Normal/Large)


HOW TO USE
1. Add the indicator to your chart
2. Adjust ATR multipliers based on your risk tolerance (higher values = more conservative)
3. Configure the EMA filter based on market conditions (enable for trending, disable for ranging)
4. Set line limits to match your visual preference and chart timeframe
5. Monitor the dashboard to track strategy performance in real-time
6. Use the TP/SL boxes as reference levels for manual trades or automation

Best Practices:
- Enable EMA filter in strongly trending markets
- Disable EMA filter if you want more trade signals but at lower quality
- Increase ATR multipliers in highly volatile markets
- Decrease ATR multipliers for tighter, more frequent trades
- Review avg win/loss ratio to ensure positive expectancy


UNIQUE FEATURES
Unlike basic Marubozu detectors, this strategy provides:
1. Automatic level tracking with memory management
2. Volatility-adjusted risk parameters instead of fixed values
3. Optional trend confirmation via EMA filter
4. Real-time performance analytics with automatic dollar conversion
5. Separate tracking of wins/losses with individual averages
6. Configurable visual display to prevent chart clutter
7. Complete transparency with all logic visible in open-source code
リリースノート
  • Added LHAMA 🦙 Line back as the default MA type (EMA is still an option if you prefer).
  • Fixed wording in stats dashboard and plots for consistency

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。