Yesterday's High Breakout Trend Following Strategy
Overview
This strategy operates based on the previous trading day's high, working in a trend-following mode. It goes long when yesterday's high is broken out, even if there are multiple breakouts in a day.
Strategy Logic
-
Use LucF function to avoid lookahead bias in backtesting.
-
Identify if it's a new trading day open. Record the day high max_today and low min_today.
-
Compare current high with max_today, update max_today if surpassed.
-
Compare current low with min_today, update min_today if breached.
-
Plot previous trading day's high and low levels.
-
Set entry point on breakout of previous day's high, GAP can be added to advance or delay entry.
-
Set stop loss percentage sl and take profit percentage tp.
-
Go long when price breaks previous trading day's high.
-
Set stop loss price and take profit price.
-
Optionally enable trailing stop loss, with activation level and offset distance.
-
Optionally close trade based on EMA crossover.
Advantage Analysis
This simple trend following strategy has the following advantages:
-
Clear and straightforward signal generation. Easy to implement.
-
Breakout of previous day's high provides trend confirmation, reducing whipsaws.
-
GAP parameter allows adjusting entry sensitivity.
-
Overall risk is controlled with clear stop loss.
-
Trailing stop can be used to lock in more profits.
-
EMA crossover avoids being trapped in downtrends.
Risk Analysis
There are some risks to note:
-
Failed breakout can cause losses. Reasonable stop loss needed.
-
Requires trending market. Whipsaws likely in ranging conditions.
-
Improper trailing stop can get stopped out prematurely.
-
Poor EMA parameter choice can make it too sensitive or lagging.
-
Multiple variables need tuning like GAP, stop loss, trailing stop etc.
Improvement Opportunities
Some ways to further optimize the strategy:
-
Use dynamic stop loss based on ATR or trend.
-
Add filter for valid breakout using standard deviation.
-
Add volatility condition to avoid false breakout in choppy markets.
-
Optimize EMA parameter for more robust signal.
-
Fine tune trailing stop parameters to match market volatility.
-
Test parameter robustness across different instruments.
-
Add dynamic position sizing mechanism.
Conclusion
The strategy is simple and practical as a typical trend following system based on previous day's high breakout. Risk management depends on stop loss primarily. With proper parameter tuning, it can perform well in trending conditions. But proper stop loss and filters are needed to avoid whipsaws. The framework can be enhanced further as a basis for trend following strategies.
/*backtest
start: 2023-09-30 00:00:00
end: 2023-10-07 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
// © TheSocialCryptoClub
//@version=5- 1
