Type/to search

Stochastic Moving Average Strategy

Cryptocurrency
Created: 2023-12-19 11:41:40
Last modified: 2 years ago
1
Follow
1779
Followers

img

Overview

This strategy combines Exponential Moving Average (EMA) with Stochastic Oscillator in a trend following and continuation manner, along with some cool functionalities. I designed this strategy especially for trading altcoins, but it works just as good on Bitcoin itself and some Forex pairs.

Strategy Logic

The strategy has 4 mandatory conditions to unlock a trading signal. Find these conditions for a long trade below (works the exact other way round for shorts)

  • Fast EMA must be higher than Slow EMA
  • Stochastic K% line must be in overbought territory
  • Stochastic K% line must cross over Stochastic D% line
  • Price as to close between slow EMA and fast EMA
    Once all the conditions are true, a trade will start at the opening of the next candle.

Advantage Analysis

The strategy combines the advantages of EMA and Stochastic to effectively capture the start and continuation of trends, suitable for medium and long term operations. At the same time, the strategy provides many customizable parameters for users to adjust based on their trading style and market characteristics.

Specifically, the advantages of the strategy include:

  1. EMA crossings judge trend direction and enhance signal stability and reliability
  2. Stochastic judges overbought and oversold levels to find reversal opportunities
  3. Combining two indicators, it has both trend following and mean reversion
  4. ATR automatically calculates stop loss distance, adjusting stops based on market volatility
  5. Customizable risk reward ratio to meet needs of different users
  6. Provides multiple customizable parameters for users to adjust based on markets

Risk Analysis

The main risks of this strategy come from:

  1. EMA crossings may have false breaks, thus generating incorrect signals
  2. Stochastic itself has lagging properties, may miss best timing for price reversals
  3. A single strategy cannot fully adapt to constantly changing market environments

To mitigate above risks, we can take following measures:

  1. Adjust EMA period parameters to avoid too many false signals
  2. Incorporate more indicators to judge trends and support levels to ensure reliable signals
  3. Define clear money management strategies to control risk exposure per trade
  4. Adopt combinational strategies so different strategies can verify signals and improve stability

Optimization Directions

The strategy can be further optimized in following aspects:

  1. Add volatility based position adjustment module. Reduce size when volatility surges and increase when calms down.
  2. Add judgement of higher timeframe trends to avoid counter trend operations, e.g. combining daily or weekly trends.
  3. Add machine learning models to aid signal generation. Train classification models based on historical data.
  4. Optimize money management modules to make stops and sizes more intelligent.

Conclusion

This strategy integrates the pros of both trend following and mean reversion, considering both higher timeframe market environments and current price behaviors. It is an effective strategy worth real time tracking and testing. Through continuous optimization on parameters, adding trend judgement modules etc, there is still large room for performance improvement, worth pouring in more research efforts.

Source
Pine
/*backtest
start: 2023-11-18 00:00:00
end: 2023-12-18 00:00:00
period: 1h
basePeriod: 15m
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/
// © LucasVivien

// Since this Strategy may have its stop loss hit within the opening candle, consider turning on 'Recalculate : After Order is filled' in the strategy settings, in the "Properties" tabs
Strategy parameters
Strategy parameters
     Trade Setup
Long Trades
Short Trades
Risk : Reward
Risk = % Equity    
riskPrctEqui
Risk = $ Amount   
riskUSD
     Stop Loss
ATR Multiplier
ATR Lookback
     Stochastic
K%
 D%
OB
 OS
Stoch. OB/OS lookback
All must be OB/OS
   
  
   
     Exp. Moving Average
Fast EMA     
Slow EMA     
     
     
     Reference Market
Reference Market Filter
Market
Timeframe
EMA Length
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)