资源加载中... loading...

Four Exponential Moving Averages and Volume Strategy

Author: ChaoZhang, Date: 2023-10-09 15:05:47
Tags:

Overview

This strategy combines multiple EMAs with different parameter settings and the EOM volume indicator to determine trends across multiple timeframes and build a trading strategy with both long-term and short-term judgments. It aims to leverage the multi-timeframe resonance of different period moving averages to uncover longer-lasting trend patterns.

Strategy Logic

The strategy uses 4 groups of EMAs with different period parameters - 13, 21, 50 and 180. These 4 EMAs establish multiple time dimensions to determine price trends and uncover longer-term trend patterns.

The strategy uses the EOM volume indicator to confirm trends. The EOM combines trading volume and price volatility range to effectively gauge buying and selling pressure. The strategy determines long conditions when EOM is above 0 and short conditions when EOM is below 0.

The strategy has two options. Option 1 goes long when shorter EMA crosses above longer EMA and closes long when shorter EMA crosses below longer EMA. Option 2 goes long when shorter EMA crosses above intermediate EMA and closes long when shorter EMA crosses below intermediate EMA. The two options allow more comprehensive trend confirmation.

Advantages

  • Using multi-timeframe EMAs to determine trends can uncover longer-term trend patterns
  • EOM volume indicator effectively gauges buying/selling pressure, avoiding false signals from temporary pullbacks
  • Two optional entry methods enable more comprehensive trend confirmation
  • Scaling out with layered exits reduces single exit exposure

Risks

  • EMAs have lag and may miss fast reversals
  • Volume indicators can give false signals
  • Multiple condition criteria creates unclear entry
  • Layered exits may be too mechanistic

Enhancement Opportunities

  • Test more EMA period combinations to find optimal parameters
  • Add other indicators like MACD for entry confirmation
  • Adopt dynamic trailing stop loss to follow trends
  • Adjust position sizing based on market conditions

Summary

This strategy integrates multi-timeframe EMA trend determination and volume indicator filtering to achieve trend following and noise removal. There is still large room for optimization by testing different parameter combinations and adding more indicators to further improve robustness. Meanwhile, dynamic stop loss and position sizing can also significantly optimize performance.


/*backtest
start: 2022-10-02 00:00:00
end: 2023-10-08 00:00:00
period: 1d
basePeriod: 1h
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/
// © SoftKill21

//@version=4
strategy("4x ema + volume", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )

//ema x 4
ema1l=input(13)
ema2l=input(21)
ema3l=input(50)
ema4l=input(180)

ema1=ema(close,ema1l)
ema2=ema(close,ema2l)
ema3=ema(close,ema3l)
ema4=ema(close,ema4l)

long1 = close > ema1 and ema1 > ema2 and ema2> ema3 and ema3 > ema4
long2 = crossover(ema1,ema2) and crossover(ema1,ema3)

short1 = close < ema1 and ema1 < ema2 and ema2< ema3 and ema3 < ema4
short2= crossunder(ema1,ema2) and crossunder(ema1,ema3)


//eom
length = input(14, minval=1)
div = input(10000, title="Divisor", minval=1)
eom = sma(div * change(hl2) * (high - low) / volume, length)


option1=input(true)
option2=input(false)

if(option1)
    strategy.entry("long",1,when=long1 and eom>0)
    strategy.close("long",when=short1 and eom<0)
 
if(option2)
    strategy.entry("long",1,when=long2 and eom>0)
    strategy.close("long",when=short2 and eom<0)   

More