Stochastic Moving Average Strategy
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:
- EMA crossings judge trend direction and enhance signal stability and reliability
- Stochastic judges overbought and oversold levels to find reversal opportunities
- Combining two indicators, it has both trend following and mean reversion
- ATR automatically calculates stop loss distance, adjusting stops based on market volatility
- Customizable risk reward ratio to meet needs of different users
- Provides multiple customizable parameters for users to adjust based on markets
Risk Analysis
The main risks of this strategy come from:
- EMA crossings may have false breaks, thus generating incorrect signals
- Stochastic itself has lagging properties, may miss best timing for price reversals
- A single strategy cannot fully adapt to constantly changing market environments
To mitigate above risks, we can take following measures:
- Adjust EMA period parameters to avoid too many false signals
- Incorporate more indicators to judge trends and support levels to ensure reliable signals
- Define clear money management strategies to control risk exposure per trade
- Adopt combinational strategies so different strategies can verify signals and improve stability
Optimization Directions
The strategy can be further optimized in following aspects:
- Add volatility based position adjustment module. Reduce size when volatility surges and increase when calms down.
- Add judgement of higher timeframe trends to avoid counter trend operations, e.g. combining daily or weekly trends.
- Add machine learning models to aid signal generation. Train classification models based on historical data.
- 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.
/*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- 1

