Type/to search

Stock Quant Trading Strategy Combining Exponential Moving Average with Trailing Stop Loss and Percentage Stop Loss

Common strategy
Created: 2024-01-03 16:25:54
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

The core of this strategy is using exponential moving average crossovers as trading signals, combined with trailing stop loss and percentage stop loss to lock in profits and control risks. The strategy is simple to implement and applicable to stocks and other financial products for quantitative trading.

Strategy Logic

  1. Calculate fast EMA and slow EMA, with fast EMA period being 20 days and slow EMA period being 50 days. Generate buy signal when fast EMA crosses above slow EMA, and sell signal when fast EMA crosses below slow EMA.

  2. After entry, set up trailing stop loss based on holding direction, e.g. 7% for long position and 7% for short position. The trailing stop loss adjusts every bar to lock in the maximum possible profit.

  3. At the same time, set stop loss price based on entry price and holding direction, e.g. 2% below entry price for long trade and 2% above entry price for short trade. The stop loss price remains unchanged to prevent excessive loss.

  4. Compare trailing stop price and stop loss price, use the one closer to market price as the final stop loss for this trade, send stop loss order.

Advantages

  1. Simple and easy to implement moving average trading signals.

  2. Trailing stop loss locks in profits to the largest extent possible, while avoiding unnecessary loss from false signals.

  3. Percentage stop loss is intuitive and easy to adjust for controlling maximum loss per trade.

  4. Combining trailing stops and fixed stops both locks in profits and controls risks.

Risks and Countermeasures

  1. Moving averages can generate false signals easily, add further filters like volume.

  2. Trailing stops sometimes trigger too early, relax the trailing percentage a bit.

  3. Improper fixed stop loss setting can be too aggressive or conservative, need to test and tune the percentage parameter.

  4. Mechanical stop loss exits could miss market reversal opportunities, incorporate technical indicators to judge stop trigger.

Optimization Directions

  1. Try different EMA combinations to find optimal balance.

  2. Add indicators like volume to filter false signals.

  3. Test more stocks to find suitable stop loss percentages.

  4. Try adaptive stops that adjust with market conditions.

  5. Incorporate indicators like RSI to determine stop loss timing.

Summary

This strategy integrates moving average trading signals, trailing stops and percentage stops. Through parameter optimization, it can achieve stable profits with strict risk control across various stocks and commodities, worth researching and continuously improving for quant traders.

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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © wouterpruym1828

//@version=5
Strategy parameters
Strategy parameters
Fast EMA period
Slow EMA period
Long Trailing Stop (%)
Short Trailing Stop (%)
Long Stop Loss (%)
Short Stop Loss (%)
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)