Type/to search

Consecutive Up/Down Strategy with Reverse and SL/TP Extension

Common strategy
Created: 2024-01-08 11:58:21
Last modified: 3 years ago
1
Follow
1802
Followers

img

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:

  1. Buy/sell filter parameters can be set for both trending and ranging markets
  2. Reverse trade allows direction choice when needed
  3. Direct reverse position reduces time with no position
  4. Multiple stop loss methods, select as needed
  5. 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:

  1. Adjust up/down bars quantity moderately, not too aggressive
  2. Test different stop loss methods, find the best fit one
  3. Use trailing stop cautiously, avoid too big losses

Optimization Directions

There is room for further optimization:

  1. Dynamically adjust up/down bars based on ATR or volatility
  2. Test stop loss/profit ratio under different holding periods
  3. Add open price filter to avoid false breakout
  4. 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.

Source
Pine
/*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.
Strategy parameters
Strategy parameters
Strategy Direction
-----------------Strategy Inputs-------------------
consecutiveBarsUp
consecutiveBarsDown
-----------------General Inputs-------------------
Use Stop Loss and Take Profit
Type Of Stop
Swing Point Lookback
Swing Point SL Perc Increment
ATR Length
ATR Multiple
Take Profit Risk Reward Ratio
Trailing Stop
Allow Direct Position Reverse
Reverse Trades
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)