
二重EMA戦略は,異なる周期のEMAを計算して,価格のトレンド方向を識別して,ポジションまたは平仓を決定するトレンド追跡戦略である.この戦略は,シンプルで実用的で,トレンドが強い市場に適用される.
この戦略は,主に2つのEMA指標,すなわち短周期9日EMAと,より長い周期21日EMAをベースにしている.それらの交差は,倉庫建設と倉庫停止の信号である.
短期EMA上から長期EMAを突破すると,価格が上昇傾向に入ると考えられ,この戦略は,この時点で多発令状を開き,価格の上昇を追跡する.短期EMA下から長期EMAを突破すると,この時点で価格が低下傾向に入ると考えられ,この戦略は,この時点で空発令状を開き,価格の下落を追跡する.
EMA指標は価格データの中のノイズを効果的にフィルターし,価格トレンドの主要な方向を識別することができる.したがって,この戦略は,より長い価格トレンドサイクルを捉えることができるように期待して,二重EMA指標をポジションとポジションの基礎として使用する.
この戦略の利点は以下の通りです.
この戦略にはいくつかのリスクがあります.
この戦略は以下の点で最適化できます.
双EMA戦略は全体的に非常に実用的なトレンド追跡戦略である.操作が簡単で,理解が容易で,強いトレンド市場において優れたパフォーマンスを発揮する.同時に,この戦略にはいくつかのリスクがあり,戦略の安定性を高めるために複数の次元から最適化することができます.全体的に,双EMA戦略は,取引の量化のための重要な参照テンプレートです.
/*backtest
start: 2023-02-21 00:00:00
end: 2024-02-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
// This can only draw so many lines. Use bar replay to go back further
strategy("Strategy Lines", shorttitle="Strategy Lines", overlay=true, max_lines_count=500)
//###########################################################################################################################################
// Replace your strategy here
//###########################################################################################################################################
shortEMA = ta.ema(close, input(9, title="Short EMA Length"))
longEMA = ta.ema(close, input(21, title="Long EMA Length"))
// Entry conditions for long and short positions
longCondition = ta.crossover(shortEMA, longEMA)
shortCondition = ta.crossunder(shortEMA, longEMA)
//###########################################################################################################################################
// Strategy Lines
//###########################################################################################################################################
var timeLow = bar_index
var line li = na
var openLPrice = 0.0000
var openSPrice = 0.0000
LongWColor = input.color(color.rgb(0,255,0,0),"Long Win Color", group="Strategy Lines")
LongLColor = input.color(color.rgb(0,0,255,0),"Long Loss Color", group="Strategy Lines")
ShortWColor = input.color(color.rgb(255,255,0,0),"Short Win Color", group="Strategy Lines")
ShortLColor = input.color(color.rgb(255,0,0,0),"Short Loss Color", group="Strategy Lines")
WinFontColor = input.color(color.rgb(0,0,0,0),"Win Font Color", group="Strategy Lines")
LossFontColor = input.color(color.rgb(255,255,255,0),"Loss Font Color", group="Strategy Lines")
LinesShowLabel = input(false,"Show Labels?",group = "Strategy Lines")
// // Start new line when we go long
// if strategy.position_size >0
// line.delete(li)
// li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=close>openLPrice?LongWColor:LongLColor)
// // Start new line when we go short
// if strategy.position_size <0
// line.delete(li)
// li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=close<openSPrice?ShortWColor:ShortLColor)
// //Delete Lines if we don't have a position open
// if strategy.position_size ==0
// li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=color.rgb(0,0,0,100))
// line.delete(li)
if LinesShowLabel
// Short Label
if strategy.position_size>=0 and strategy.position_size[1] <0
label.new(
timeLow, na,
text=str.tostring((openSPrice-close[1])/(syminfo.mintick*10)),
color=close[1]<openSPrice?ShortWColor:ShortLColor,
textcolor=close[1]<openSPrice?WinFontColor:LossFontColor,
size=size.small,
style=label.style_label_down, yloc=yloc.abovebar)
// Long Label
if strategy.position_size<=0 and strategy.position_size[1] >0
label.new(
timeLow, na,
text=str.tostring((close[1]-openLPrice)/(syminfo.mintick*10)),
color=close[1]>openLPrice?LongWColor:LongLColor,
textcolor=close[1]>openLPrice?WinFontColor:LossFontColor,
size=size.small,
style=label.style_label_down, yloc=yloc.abovebar)
// Open long position and draw line
if (longCondition)
//strategy.entry("Long", strategy.long)
// timeLow := bar_index
// li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=close>openLPrice?LongWColor:LongLColor)
openLPrice := close
// Open short position and draw line
if (shortCondition)
//strategy.entry("Short", strategy.short)
// timeLow := bar_index
// li := line.new(timeLow, close[bar_index-timeLow], bar_index, close, width=2, color=close<openSPrice?ShortWColor:ShortLColor)
openSPrice := close
//###########################################################################################################################################
// Strategy Execution (Replace this as well)
//###########################################################################################################################################
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)