Type/to search

Trailing Stop Loss Strategy

Common strategy
Created: 2024-01-12 10:47:38
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

This strategy calculates fast and slow moving averages to determine the trend. It goes long when the fast moving average crosses over the slow moving average, and sets a dynamic trailing stop loss to lock in profits when the price changes by a certain percentage.

Strategy Logic

The strategy uses the golden cross of fast and slow moving averages to determine the beginning of an uptrend. Specifically, it calculates the simple moving average of closing prices over a certain period, compares the values of the fast and slow moving averages, and judges the beginning of an uptrend when the fast moving average crosses over the slow one.

After opening a long position, the strategy does not set a fixed stop loss, but uses a dynamic trailing stop loss to lock in profits. The stop loss line is set based on: Highest Price * (1 - Stop Loss Percentage). This allows the stop loss line to move up as the price rises. When the price falls by a certain percentage, the stop loss will be triggered to exit the position.

The advantage of this approach is that it allows unlimited chasing of uptrends, while locking in profits once they reach a certain level through the stop loss.

Advantage Analysis

The main advantages of this trailing stop loss strategy are:

  1. It allows unlimited chasing of trends without missing out large moves. Fixed stop losses often get stopped out at the beginning of major trends.

  2. It locks in profits by setting a stop loss percentage. Simply chasing trends without a stop loss can lead to losses when the trend ends. The stop loss locks in gains.

  3. It is more flexible than fixed stop losses. Fixed stops can only be set to one price, while this stop loss moves with the highest price.

  4. It has lower pullback risks. Fixed stops are often far from the highest price, leading to premature stop outs on normal pullbacks. This stop loss stays close to the highest price to avoid being stopped out unnecessarily.

Risk Analysis

The strategy also has some risks:

  1. The indicator used for entry signals may be unstable and produce false signals.

  2. There is only a single stop loss approach without considering other factors. Major market changes can invalidate the strategy.

  3. There are no profit targets, relying solely on the stop loss. Ineffective stop loss can lead to large losses.

  4. The parameters like moving average periods need further optimization.

Optimization Directions

The strategy can be improved in several areas:

  1. Add more indicators to confirm entries and avoid false signals, e.g. volume.

  2. Add profit taking when profits reach a certain percentage.

  3. Improve stop loss safety by dynamically adjusting the stop distance in exceptional market events.

  4. Optimize parameters like trading instruments and trading sessions. Different products and sessions require parameter adjustments.

  5. Add machine learning to dynamically adjust parameters and optimize indicators and stop loss levels automatically.

Summary

The overall logic of this strategy is sound and reasonable. Using fast and slow moving averages to determine trends is a classic approach. Trailing stop loss is also effective for locking in profits and reducing risks. However, continual testing and optimization is needed for the indicators and parameters to make the strategy consistently profitable. At the same time, major market changes that could invalidate the strategy need to be guarded against by improving the overall logic and framework and adding safeguards.

Source
Pine
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ 
//  -----------------------------------------------------------------------------
Strategy parameters
Strategy parameters
Strategy
Fast SMA Length
Slow SMA Length
Enable Trailing
Long Stop Loss %
Backtest Period
From Date
To Date
Plot
Show Backtest Range
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)