Trailing Stop Loss Strategy Based on Price Gaps
Overview
This strategy adopts the price gap principle to go long when price breaks recent lows, with stop loss and take profit orders to trail the lowest price for profit taking.
Strategy Logic
It identifies gaps when price breaks below the lowest price in recent N hours, goes long based on configured percentage, with stop loss and take profit orders. Stop loss line and take profit line move according to price action. The logic is:
- Calculate lowest price in recent N hours as binding price
- Go long when realtime price is below binding price * buy percent
- Set take profit based on entry price * sell percent
- Set stop loss based on entry price - entry price * stop loss percent
- Position size is percent of strategy equity
- Trail stop loss line with lowest price
- Close position when take profit or stop loss is triggered
Advantage Analysis
The advantages of this strategy:
- Utilize price gap concept, improve winning rate
- Automatic trailing stop loss to lock in most profits
- Customizable stop loss and take profit percentage for different markets
- Works well for instruments with obvious rebounds
- Simple logic and easy to implement
Risk Analysis
There are also some risks:
- Breakout of gaps may fail with lower lows
- Improper stop loss or take profit settings may cause premature exit
- Require periodic parameter tuning for market changes
- Limited applicable instruments, may not work for some
- Manual intervention needed from time to time
Optimization Directions
The strategy can be improved in the following aspects:
- Add machine learning models for automatic parameter tuning
- Add more types of stop loss/take profit, e.g. trailing stop loss, bracket orders
- Optimize stop loss/take profit logic for smarter exits
- Incorporate more indicators to filter out false signals
- Expand to more instruments to improve universality
Conclusion
In conclusion, this is a simple and effective trailing stop loss strategy based on price gaps. It reduces false entries and locks in profits effectively. There is still much room for improvements in parameters tuning and signal filtering. It is worth further research and refinement.
/*backtest
start: 2022-11-21 00:00:00
end: 2023-11-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title="Squeeze Backtest by Shaqi v1.0", overlay=true, pyramiding=0, currency="USD", process_orders_on_close=true, commission_type=strategy.commission.percent, commission_value=0.075, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=100, backtest_fill_limits_assumption=0)
strategy.risk.allow_entry_in(strategy.direction.long)- 1

