Name
基于周线EMA的日内交易策略Daily-Trading-Strategy-Based-on-Weekly-EMAs
Author
ChaoZhang
Strategy Description
[trans]
这个策略的核心思想是将周线上的EMA指标映射到日内交易中,以获取更长期趋势的支持,指导日内交易决策。
该策略首先在代码中计算了日线上的6日、12日、26日、52日EMA,以及对应周线EMA的参数设置下的42日、84日、182日、364日EMA。
然后,根据42日EMA和84日EMA的金叉、死叉来判断长期趋势;根据84日EMA和182日EMA的金叉、死叉来判断中期趋势。
当较短周期EMA上穿较长周期EMA时,进行长仓入场;当较短周期EMA下穿较长周期EMA时,进行平仓出场。
通过这种映射方法,我们在日内交易中获得了周线级别EMA指标的支撑,可以过滤掉部分噪音,锁定较大的趋势机会。
这种策略结合了日内交易的灵活性以及周线EMA的稳定性,主要有以下优势:
-
周线EMA能有效过滤市场噪音,识别真正的趋势走势。日内交易则可以根据日内FORMATION选择更精准的入场时机。
-
周线EMA参数设置更稳定,不容易被短期价格震荡所影响。同时日内形态结合趋势判断,出场更及时。
-
EMA的金叉、死叉可以清晰判断阶段性趋势转折点。辅以日内交易来获利,整体胜率较高。
-
不同周期EMA组合使用,可以在长、中、短不同级别锁定趋势机会。
-
策略交易频次低,适合长线持有。可以减少交易次数带来的滑点损失。
该策略的主要风险有:
-
周线EMA入场信号可能滞后,无法把握价格变化最早的时机点。
-
日内出场依靠EMA交叉,没有考虑形态、波动等因素,可能会过早离场。
-
EMA多空交叉次数较少,容易形成单边持仓时间过长的情况。
-
没有止损机制,回撤风险较大,需要人工积极管理。
-
参数设置较粗放,不同币种需要调整才能达到最佳效果。
可以通过以下方法降低风险:
-
结合其他指标识别ENTRY 形态,提前布局EMA入场点。
-
增加离场规则,如止损,收敛停利等,避免单边持仓时间过长。
-
优化EMA周期参数,测试不同币种适合的周期组合。
-
多级别交易,不同EMA周期进行分层持仓,降低单边持仓风险。
该策略还可以从以下几个方面进行优化:
-
增加日内交易的准入规则,如形态、成交量等判定,过滤入场 noise。
-
结合stoch、MACD等指标判定超买超卖,细化入场出场。
-
增加止损、止盈机制,降低回撤风险,锁定利润。
-
优化EMA周期参数,测试不同周期组合的效果。
-
尝试不同的EMA,如DEMA,TEMA等参数设置,提高平滑性。
-
增加仓位管理机制,不同EMA信号采用不同仓位。
-
研究不同品种参数设置,制定适合不同交易对的策略。
-
探索机器学习方法,实现EMA参数的动态优化。
这是一个非常适合长线持仓的趋势跟踪策略。它巧妙地融合周线趋势判断和日内交易执行。通过适当优化,可以成为一个非常实用的多时间框架交易系统。
||
The core idea of this strategy is to map the EMA indicators from weekly timeframe to daily trading, in order to get support from longer term trends and guide daily trading decisions.
The strategy first calculates the 6-day, 12-day, 26-day, 52-day EMAs on the daily chart, as well as the 42-day, 84-day, 182-day, 364-day EMAs corresponding to weekly EMA parameter settings.
Then, the crosses of 42-day EMA and 84-day EMA are used to determine the long-term trend; the crosses of 84-day EMA and 182-day EMA are used to determine the medium-term trend.
When shorter period EMA crosses above longer period EMA, go long; when shorter period EMA crosses below longer period EMA, close positions.
Through this mapping method, we get support from weekly level EMA indicators in daily trading, which helps filter some noise and capture larger trend opportunities.
This strategy combines the flexibility of daily trading and the stability of weekly EMAs, with the following advantages:
-
Weekly EMAs can effectively filter market noise and identify real trend moves. Daily trading can then choose more precise entry based on daily formations.
-
Weekly EMA parameters are more stable, less affected by short-term price fluctuations. At the same time, daily formations combined with trend judgment result in more timely exits.
-
EMA crosses can clearly identify cyclical trend reversal points. Profiting from them through daily trading leads to relatively high win rate.
-
Different period EMA combinations capture trend opportunities across long, medium and short terms.
-
The strategy has low trading frequency, suitable for long holding. It reduces slippage cost from excessive trading.
The main risks of this strategy are:
-
Weekly EMA entry signals may lag, unable to catch the earliest price change timing.
-
Exits rely on EMA crosses, without considering formations, volatility etc, may lead to premature exit.
-
Few EMA crosses tend to result in over extended one-sided holding.
-
No stop loss means high drawdown risk, requires active human management.
-
Coarse parameter tuning, needs adjustment for optimal performance on different coins.
Risks can be reduced through:
-
Identify entry formations with other indicators, take positions ahead of EMA signals.
-
Add exit rules like stop loss, take profit to avoid over holding.
-
Optimize EMA periods, test suitable period combos for different coins.
-
Multi-tier trading, different EMAs for layered positions, lower one-sided holding risk.
The strategy can be further optimized in the following aspects:
-
Add rules on daily entry, like formations, volume etc to filter noise.
-
Combine stoch, MACD to judge overbought-oversold for finer entry/exit.
-
Add stop loss, take profit to lower drawdown, lock in profit.
-
Optimize EMA periods, test combos of different periods.
-
Try different EMAs like DEMA, TEMA for smoother parameters.
-
Add position sizing based on different EMA signals.
-
Research parameters for different trading pairs.
-
Explore machine learning methods for dynamic EMA optimization.
This is an excellent trend following strategy suitable for long-term holding. It cleverly combines weekly trend judgment and daily execution. With proper enhancements, it can become a very practical multi-timeframe trading system.
[/trans]
Strategy Arguments
Argument | Default | Description |
---|---|---|
v_input_1 | true | From Month |
v_input_2 | true | From Day |
v_input_3 | 2017 | From Year |
v_input_4 | true | To Month |
v_input_5 | true | To Day |
v_input_6 | 9999 | To Year |
Source (PineScript)
/*backtest
start: 2023-08-20 00:00:00
end: 2023-09-19 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=1
strategy("Investing Weekly mapped to Daily", overlay=true, pyramiding=100)
// === PLOTTING EMA ===
plot(ema(close, 6), color=aqua, transp=0, linewidth=2, title="ema6")
plot(ema(close, 12), color=white, transp=0, linewidth=2, title="ema12")
plot(ema(close, 26), color=#9802FF, transp=0, linewidth=2, title="ema26")
plot(ema(close, 52), color=orange, transp=0, linewidth=2, title="ema52")
plot(ema(close, 42), color=aqua, transp=0, linewidth=5, title="W-ema6")
plot(ema(close, 84), color=white, transp=0, linewidth=5, title="W-ema12")
plot(ema(close, 182), color=#9802FF, transp=0, linewidth=5, title="W-ema26")
plot(ema(close, 364), color=orange, transp=0, linewidth=5, title="W-ema52")
// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2017, title = "From Year", minval = 2017)
ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2017)
start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
window() => true // create function "within window of time"
// === STRATEGY FOR CRYPTO ===
ema42= ema(close, 42)
ema84= ema(close, 84)
ema182= ema(close, 182)
enterLong1 = cross(ema42, ema84) and ema42 > ema84
exitLong1 = cross(ema42, ema84) and ema42 < ema84
enterLong2 = cross(ema84, ema182) and ema84 > ema182
exitLong2 = cross(ema84, ema182) and ema84 < ema182
strategy.entry(id="Entry_1", long=true, when=enterLong1)
strategy.entry(id="Entry_2", long=true, when=enterLong2)
strategy.entry(id="Exit_1", long=false, when=exitLong1)
strategy.entry(id="Exit_2", long=false, when=exitLong2)
Detail
https://www.fmz.com/strategy/427398
Last Modified
2023-09-20 17:11:52