Simple Trailing Stop & Buy Strategy Based on Percentage
Overview
This strategy implements a simple percentage-based trailing stop and trailing buy. By experimenting with different percentage combinations across timeframes and charts, the strategy parameters can be optimized.
Strategy Logic
The strategy mainly uses two metrics to achieve trailing stop loss and trailing buy:
-
Trailing Stop Line (TSL): Calculated based on recent N bars of closing prices and stop loss offset percentage set by user. Triggers stop loss when price falls below this line.
-
Trailing Buy Line (TBL): Calculated based on recent N bars of highest prices and buy offset percentage set by user. Triggers buy when price rises above this line.
By comparing price with these two metrics, the stop loss and trailing buy rules are implemented.
Advantages
The advantages of this strategy are:
-
Simple and intuitive, easy to understand and implement.
-
Flexible stop loss and trailing buy through parameter adjustment.
-
Applicable across markets and timeframes.
-
Allows trend following and timely stop loss.
Risks
The risks of this strategy include:
-
Improper parameter setting may cause over-aggressive stop loss or buys.
-
Frequent trading and slippage in ranging markets.
-
Requires parameter optimization for different market characteristics.
Enhancement Opportunities
The strategy can be enhanced through:
-
Adaptive algorithms to auto optimize stop and buy parameters.
-
Addition of position sizing and risk management modules.
-
Incorporation of other indicators to gauge overall trend to avoid whipsaws.
Conclusion
In summary, this is a very simple and intuitive trend following strategy. With parameter tuning it can be adapted across markets. Further incorporation of adaptive algorithms and additional filters can improve robustness. Overall it provides a basic yet effective framework for quantitative trading.
/*backtest
start: 2023-01-12 00:00:00
end: 2024-01-18 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
//Developed from ©Finnbo code
strategy("Simple Trailing Buy & Stop Strategy", overlay=true)
offset = input(defval=1.5, title="Stop Offset %", type=float, minval=0.1, maxval=100, step=0.1)- 1

