OPEN-SOURCE SCRIPT

EMA Grid + Martingale Strategy (Long-Only) with Cooldown

461
Title:
EMA Grid + Martingale Strategy (Long-Only) with Cooldown

Short Summary:
A long-only strategy combining EMA trend filters, grid-based entries, optional martingale sizing, and a cooldown feature to manage position timing and exits.

Full Description:
This strategy uses a 4-EMA trend confirmation system to detect bullish momentum, then deploys a grid-style entry method with optional martingale position sizing. It includes a cooldown mechanism to prevent reentry too soon after a completed trade cycle.

How It Works
1. Trend Confirmation: Two EMA groups (fast/slow) determine whether market conditions are bullish.
2. Initial Entry: A new position is entered when both EMA groups confirm an uptrend and no position is currently active.
3. Grid Entries: Additional long entries are placed when price drops by a defined pip distance from the last entry, respecting the maximum number of entries.
4. Martingale Sizing (Optional): Grid orders can increase in size with each level using a customizable multiplier.
5. Weighted-Average Exit: All positions close once price reaches or exceeds the average entry price plus a buffer.
6. Cooldown Timer: After closing a position set, the strategy waits a defined number of bars before opening a new grid.

Key Features
• 4 customizable EMAs for trend confirmation.
• Dynamic grid-style long entries based on pip intervals.
• Optional martingale-style position sizing.
• Weighted-average price exit logic with buffer control.
• Cooldown bar period to limit overtrading.
• Suitable for optimization and backtesting with full control over inputs.

Use Cases
• Designed for trending markets where pullbacks present entry opportunities.
• Helps manage staged entries while avoiding premature reentry.
• Ideal for testing martingale and grid-based strategies with exit precision.

Note: This strategy is for testing and educational purposes only. It does not guarantee profits and is not financial advice.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.