Overlay Trend Signals Strategy
Overview
This strategy generates trading signals by calculating the Directional Movement Indexes (DMI) DI+ and DI- along with Average Directional Index (ADX) and Exponential Moving Average (EMA). It triggers a long signal when DI+ crosses above DI- and ADX is above 20. A short signal is triggered when DI- crosses below DI+ and ADX is above 25. The stop loss signal is when DI- crosses above DI+ with ADX above 30.
Strategy Logic
-
Calculate DI+, DI-, ADX
- Use ta.dmi() to compute DI+, DI-, ADX
- DI+/DI- measures directional price movement
- ADX measures strength of price movement
-
Calculate Exponential Moving Average
- Use custom my_ema() function to compute EMA
- EMA smoothes price data
-
Generate trading signals
- Long signal: DI+ crosses above DI- and ADX > 20 and close > EMA
- Indicates upward trend and increased volatility
- Short signal: DI- crosses below DI+ and ADX > 25 and close < EMA
- Indicates downward trend and high volatility
- Long signal: DI+ crosses above DI- and ADX > 20 and close > EMA
-
Set stop loss
- Long stop loss: DI- crosses above DI+ and ADX > 30
- Indicates trend reversal
- Short stop loss: DI+ crosses below DI- and ADX > 30
- Indicates trend reversal
- Long stop loss: DI- crosses above DI+ and ADX > 30
In summary, this strategy combines momentum and trend analysis indicators to trade when strong price trends emerge, with stop losses to limit losses.
Advantage Analysis
- Dual DI avoids false signals
- Single DI can give false signals, dual DI ensures trend
- ADX threshold requires increased volatility
- Only trades high volatility moves, avoids ranging
- EMA complements DI
- EMA identifies mid/long term trends
- Strict stop loss
- Cuts losses quickly
Risk Analysis
- Frequent stop loss
- Volatile swings may trigger frequent stops
- Parameter dependence
- Optimal DI and ADX parameters need to be found
- Low trade frequency
- Strict rules reduce trades
Can optimize by expanding stop loss, tuning parameters, adding filters to increase frequency.
Optimization Opportunities
- Parameter optimization
- Optimize DI and ADX parameters
- Add filters
- Volume, divergence etc.
- Widen stop loss
- Relax stops to reduce frequency
Conclusion
This strategy combines momentum and trend analysis indicators to trade strong trends, with strict stops to control risk. Can further improve performance through parameter optimization, additional filters, and relaxed stops.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Tamil_FNO_Trader
//@version=5- 1

