Mirrorpip Supertrend Martingale Strategy: Recovering Trend-Following Losses with Intelligent Position Sizing
Introduction
The Mirrorpip Supertrend Martingale Strategy is an advanced trend-following system designed to solve one of the biggest challenges faced by traditional Supertrend traders: consecutive false signals during sideways market conditions. Instead of blindly taking every Supertrend reversal, this strategy intelligently waits for a predefined number of failed Supertrend trades before entering the market. Once an entry is triggered, the strategy uses a configurable Martingale position-sizing model to recover previous losses and capture profits during the next successful trend. The strategy is fully automated and can be deployed on Mirrorpip using TradingView alerts and webhooks.What Is the Supertrend Indicator?
Supertrend is one of the most popular trend-following indicators available in TradingView. The indicator generates:- Buy signals when trend changes from bearish to bullish
- Sell signals when trend changes from bullish to bearish
- Dynamic support and resistance levels
- Clear trend direction
Here is the source code of the strategy \
The Core Concept
Most traders take every Supertrend reversal. This strategy does not. Instead, it tracks how many consecutive Supertrend trades have failed. Only after a predefined number of losing trades does it begin trading. The logic is based on the observation that:Multiple consecutive failed Supertrend signals are often followed by a strong trending move.By waiting for several failed signals, the strategy attempts to enter when the probability of a sustained trend becomes higher.
Key Parameter: Minimum ST Loss Trades
This is the most important setting in the strategy.Example
Suppose: Min ST Loss Trades = 3 The strategy behaves as follows:Trade 1
Supertrend Buy Signal Result: Loss Loss Count = 1 No trade taken.Trade 2
Supertrend Sell Signal Result: Loss Loss Count = 2 No trade taken.Trade 3
Supertrend Buy Signal Result: Loss Loss Count = 3 No trade taken.Trade 4
Supertrend Sell Signal Loss count requirement satisfied. Strategy now enters the market. This becomes the first Martingale cycle trade.Why This Works
Trending indicators struggle during sideways markets. During a range:- Buy signal fails
- Sell signal fails
- Buy signal fails
- Sell signal fails
Martingale Recovery System
Once the strategy starts trading, it enters Martingale mode. If a trade loses, the next trade size increases according to the selected Martingale model. The objective is to recover previous losses when the next profitable trend emerges. The strategy remains in Martingale mode until:- A profitable trade occurs
- Target is hit
- Net cycle becomes profitable
Arithmetic Martingale
In Arithmetic Martingale, position size increases linearly. Example:Example
Base Size = $100 Sequence:- Trade 1 = $100
- Trade 2 = $200
- Trade 3 = $300
- Trade 4 = $400
- Lower capital requirements
- Slower drawdown growth
- More conservative
- Moderate risk traders
- Smaller accounts
- Volatile crypto markets
Geometric Martingale
In Geometric Martingale, size doubles after every loss. Example:Example
Base Size = $100 Sequence:- Trade 1 = $100
- Trade 2 = $200
- Trade 3 = $400
- Trade 4 = $800
- Trade 5 = $1600
- Faster recovery
- Requires fewer winning trades
- Higher capital requirement
- Larger drawdowns
- Greater liquidation risk if leverage is excessive
- Well-capitalized accounts
- Strongly trending markets
- Advanced traders
Cycle Reset Mechanism
One unique feature of this strategy is the reset logic. When a profitable trade occurs: ✓ Martingale cycle ends ✓ Position size resets to base size ✓ Consecutive loss counter resets ✓ Strategy waits again for new Supertrend failures This prevents unnecessary overtrading during favorable market conditions.Stop Loss Configuration
Users can define custom stop losses. Available modes:Fixed Point Stop Loss
Example: SL = 100 Points Long Entry = 50,000 Stop Loss = 49,900Percentage Stop Loss
Example: SL = 2% Long Entry = 50,000 Stop Loss = 49,000 This allows the strategy to adapt to instruments with different volatility profiles.Take Profit Configuration
Users can also define custom profit targets.Fixed Point Target
Example: Target = 200 Points Entry = 50,000 Exit = 50,200Percentage Target
Example: Target = 5% Entry = 50,000 Exit = 52,500 This provides additional flexibility beyond standard Supertrend exits.Example Trade Sequence
Let’s assume:- Supertrend ATR Length = 10
- Multiplier = 3
- Minimum ST Loss Trades = 3
- Martingale Type = Arithmetic
Market Condition
Signal 1 = Loss Signal 2 = Loss Signal 3 = Loss Loss requirement met.Trade A
Position Size = 1x Result = LossTrade B
Position Size = 2x Result = LossTrade C
Position Size = 3x Result = Profit Cycle becomes profitable. Strategy resets. Wait for next 3 failed Supertrend trades.Suitable Markets
This strategy performs best in:- Cryptocurrency Futures
- Index Futures
- Commodity Futures
- Forex Markets
- Trending Stocks
Risk Management Considerations
Although Martingale can improve recovery rates, it also increases risk. Before deploying:- Use sensible leverage
- Define maximum Martingale levels
- Test extensively using historical data
- Understand worst-case drawdowns
- Allocate sufficient capital
Mirrorpip Automation Setup
This strategy can be fully automated through Mirrorpip. Workflow: TradingView Strategy → TradingView Alert → Mirrorpip Webhook → Exchange Account → Trade Execution Users can:- Run the strategy 24/7
- Connect multiple exchanges
- Deploy across multiple symbols
- Monitor performance from a unified dashboard
- Analyze drawdown, win rate, Sharpe ratio, and profitability metrics