This strategy uses Double Exponential Moving Average (DEMA) to calculate price volatility, and further smoothes the volatility to detect trends in price fluctuations, going long when volatility rises and short when volatility falls.
Calculate Double Exponential Moving Average (DEMA) of price, formula: DEMA = 2*EMA(price, N) - EMA(EMA(price, N), N)
Calculate price volatility relative to DEMA: Volatility = (price - DEMA) / price * 100%
Apply DEMA smoothing on volatility again to get trend signal of volatility
When smoothed volatility crosses above a level, go long. When it crosses below, go short.
Can set to trade only during specific time period.
DEMA catches trend changes faster than simple moving averages.
Volatility reflects market sentiment, rise in volatility represents dominance of bulls, fall represents bears.
Smoothing volatility filters out short-term noise and captures major trend.
Trading in specific time periods avoids unnecessary slippage costs.
Stop loss and exit strategies control risk.
DEMA may lag during strong trends, missing best entry points.
Volatility index may give false signals, should combine with other indicators.
Should set stop loss to prevent magnified losses.
Missing opportunities outside trading time period.
Trading time period needs testing on historical data, improper time may reduce profits.
Optimize DEMA parameters, use smaller N values.
Combine other indicators like RSI, MACD for confirmation.
Set stop loss based on historical data and maximum tolerable loss.
Optimize trading time period selection.
Test optimal trading times separately for different products.
Test different DEMA parameter combinations for best smoothing.
Try other moving averages like EMA, SMA.
Additional smoothing of volatility with different parameters.
Add other indicators for multi-factor verification.
Use machine learning to auto-optimize entry and exit parameters.
Test optimal parameters separately for different products.
Add stop loss and exit strategies to control risk.
This strategy captures trend changes in market sentiment by calculating smoothed DEMA volatility, going long when volatility rises and short when it falls. But DEMA lag and false signals are risks. Parameters should be optimized, strict stop loss implemented, and other indicators combined for confirmation. If used properly, this strategy can catch trend reversals and provide good investment returns.
/*backtest start: 2022-10-17 00:00:00 end: 2023-10-23 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version= 2 strategy("DEMA of DPD Strategy ",shorttitle="DPD% DEMA " ,overlay=false) buyper =input(-2) sellper=input(2) demalen = input(50,title="Dema Length") e1= ema(close,demalen) e2=ema(e1,demalen) demaprice = 2 * e1 - e2 price=close demadifper = ((price-demaprice)/price)*100 OverDemaPer = input(1, title="Band for OverBought") UnderDemaPer= input(-1,title="Band for OverSold") band1 = hline(OverDemaPer) band0 = hline(UnderDemaPer) zeroline=0 fill(band1, band0, color=green, transp=90) demalen2 = input(21,title="DEMA to Calculate dema of DPD") demaofdpd =ema(demadifper,demalen2) demaofdpd2 =ema(demaofdpd,demalen2) resultstrategy = 2*demaofdpd - demaofdpd2 plot(resultstrategy,color=blue) yearfrom = input(2018) yearuntil =input(2019) monthfrom =input(6) monthuntil =input(12) dayfrom=input(1) dayuntil=input(31) if ( crossover(resultstrategy,buyper) ) strategy.entry("BUY", strategy.long, stop=close, oca_name="TREND", comment="BUY") else strategy.cancel(id="BUY") if ( crossunder(resultstrategy,sellper) ) strategy.entry("SELL", strategy.short,stop=close, oca_name="TREND", comment="SELL") else strategy.cancel(id="SELL")template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6