Consecutive Up/Down Strategy with Reverse and SL/TP Extension
Overview
This strategy is an extension of the built-in consecutive up/down bars strategy on TradingView. It has flexible direction settings that allow reverse trading. Also, integrated with various stop loss methods like swing points/low, ATR stop, and strategy stop, as well as take profit settings accordingly. This makes the strategy better at risk management while keeping the original trading signals.
Strategy Logic
The strategy mainly uses the consecutive up or down bars to generate buy and sell signals. Users can configure the needed consecutive up bars for buy signals, and consecutive down bars for sell signals.
Also, the reverse trade option is added. By enabling it, the original buy signals become sell signals, and vice versa, thus completing the trade reversal.
For entries and exits, direct position reverse is supported to reduce the time with no position.
For stop loss and take profit, swing points/low, ATR stop and strategy stop are provided for choice. The stop loss method will combine with position direction to pick swing low or high as aggressive stop, or use ATR to dynamically define stop price. Take profit sets a fixed distance based on entry price.
If trailing stop enabled, the strategy can loosen stop distance when losing, and tighten when profiting. This achieves automatic trailing effect.
Advantage Analysis
The biggest advantage of this strategy is flexibility to adapt to different market conditions:
- Buy/sell filter parameters can be set for both trending and ranging markets
- Reverse trade allows direction choice when needed
- Direct reverse position reduces time with no position
- Multiple stop loss methods, select as needed
- Trailing stop available for automatic effect
Risk Analysis
The main risks are too many consecutive bars leading to missing trades, and aggressive stop loss causing extended losses. Suggestions are:
- Adjust up/down bars quantity moderately, not too aggressive
- Test different stop loss methods, find the best fit one
- Use trailing stop cautiously, avoid too big losses
Optimization Directions
There is room for further optimization:
- Dynamically adjust up/down bars based on ATR or volatility
- Test stop loss/profit ratio under different holding periods
- Add open price filter to avoid false breakout
- Integrate other indicators for better signal quality
Conclusion
This strategy makes beneficial extensions to the base strategy for better risk control and more flexible trading. It is an effective momentum strategy that is easy to optimize and trade live.
/*backtest
start: 2023-01-07 00:00:00
end: 2023-08-30 05:20:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// Extension of the built-in strategy by Tradingview. The strategy buys after an X amount of
// consecutive bullish bars and viceversa for selling. This logic can be reversed and a Stop Loss
// with Take Profit can be added. There's also an option to adapt the SL into a Trailing Stop.
- 1

