Type/to search

Trailing Buy Strategy

Cryptocurrency
Created: 2023-10-09 14:53:02
Last modified: 3 years ago
1
Follow
1781
Followers

Overview

The trailing buy strategy is a trend following strategy. When the fast moving average crosses over the slow moving average, it triggers an open position signal. Unlike opening position directly, this strategy will not enter the market immediately after the open position signal is triggered, but will execute the buy order only when the price reaches certain conditions. This can increase the profit of the strategy to some extent.

Principles

This strategy is based on a moving average crossover system with two moving averages. The fast moving average and the slow moving average are calculated respectively. When the fast moving average crosses over the slow moving average, a long signal is generated.

The execution logic will be different when the trailing buy option is enabled:

  1. When the long signal is triggered, instead of buying directly, record the lowest price at that time.

  2. Then calculate the buy price threshold according to the trailing buy percentage, i.e. lowest price * (1 + percentage).

  3. In subsequent bars, keep comparing the current bar's lowest price with the buy price threshold.

  4. When the lowest price crosses over the buy price threshold, execute the buy order.

  5. In this way, we can enter the market at a better price point after the trend is confirmed.

Advantage Analysis

The advantages of this strategy are:

  1. Using trailing buy can avoid the risk of false breakout by entering the market after the trend becomes more obvious.

  2. Through trailing buy, better prices can be achieved, improving profit to some extent.

  3. This strategy is simple and easy to implement.

  4. The trailing buy stepping percentage is customizable, making the strategy more flexible.

  5. The moving average periods can be customized to adapt to different market environments.

Risk Analysis

There are also some risks in this strategy:

  1. Trailing buy may cause certain lag and miss the opportunity to enter.

  2. Improper setting of the trailing buy stepping percentage may result in inability to buy.

  3. Improper moving average periods may produce more false signals.

  4. The strategy may suffer severe losses in ranging markets.

  5. This is a simple strategy with room for parameter optimization.

The corresponding measures:

  1. Shorten the trailing buy stepping percentage properly to reduce lag.

  2. Test different percentage settings to find the optimal.

  3. Optimize moving average periods to adapt the market.

  4. Add other filters to avoid ranging markets.

  5. Consider adding a stop loss to reduce losses.

Optimization Directions

The strategy can be optimized in the following directions:

  1. Add price-volume indicators like Klinger to avoid price-volume mismatch.

  2. Add volume condition judgments, only buy when volume expands.

  3. Optimize moving average periods for different products.

  4. Add volatility indicators to avoid ranging zones.

  5. Add ATR stop loss.

  6. Consider making the stepping percentage dynamic, stepping faster when trend is more obvious.

Conclusion

In summary, the trailing buy strategy improves the strategy by trailing the price to better entry points while keeping it simple. But there are still some risks in this strategy that require further optimization to adapt more market situations. Overall, this strategy provides a reference-worthy idea for quantitative trading.

Source
Pine
/*backtest
start: 2023-10-01 00:00:00
end: 2023-10-08 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ 
//  -----------------------------------------------------------------------------
Strategy parameters
Strategy parameters
Filters
From
fromDate
To 
toDate
Strategy
Fast/Slow SMA Length
slowMALen
Buy
Enable Trailing
Trailing Buy Deviation %
Source Buy
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)