
移動平均線交差取引戦略は,異なる周期の移動平均を計算し,金叉または死叉の発生時に買ったり売ったりする,技術分析型の取引戦略に属している.この戦略は,単純で使いやすい,資金占有量が少ない,引き戻しは小さい,中長線操作に適している.
この戦略は,20周期と50周期の指数移動平均 ((EMA) を計算することによって行う. 20周期EMAの上に50周期EMAを穿越したときの買取操作を行う. 20周期EMAの下の50周期EMAを穿越したときの売り込み操作を行う.
EMA指数指数移動平均は,最近のデータに重み付けている.EMAの計算式は:
EMAtoday = (Pricetoday * k) + EMAyesterday * (1-k)
k = 2/ (周期数+1) で
このように,短期のEMA上に長期のEMAを突破すると,価格動向がブルイッシュ,LONG;短期のEMAの下に長期のEMAを突破すると,価格動向がベアリス,SHORT。
この戦略の利点は以下の通りです.
この戦略には以下のリスクもあります.
この戦略は,以下の点で最適化できます.
移動平均クロスライン取引戦略は,理解し,実行し,市場テストを経て容易に実行できる,シンプルで効果的な技術的な取引戦略の1つである.パラメータ最適化,補助条件の追加などの手段によって,取引リスクをさらに軽減し,戦略の安定性を向上させることができる.この戦略は,量化取引の基本的なモジュールになることができる.
/*backtest
start: 2022-11-20 00:00:00
end: 2023-11-26 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/
// © brandlabng
//@version=5
//study(title="Holly Grail", overlay = true)
strategy('HG|E15m', overlay=true)
src = input(close, title='Source')
price = request.security(syminfo.tickerid, timeframe.period, src)
ma1 = input(20, title='1st MA Length')
type1 = input.string('EMA', '1st MA Type', options=['EMA'])
ma2 = input(50, title='2nd MA Length')
type2 = input.string('EMA', '2nd MA Type', options=['EMA'])
price1 = if type1 == 'EMA'
ta.ema(price, ma1)
price2 = if type2 == 'EMA'
ta.ema(price, ma2)
//plot(series=price, style=line, title="Price", color=black, linewidth=1, transp=0)
plot(series=price1, style=plot.style_line, title='1st MA', color=color.new(#219ff3, 0), linewidth=2)
plot(series=price2, style=plot.style_line, title='2nd MA', color=color.new(color.purple, 0), linewidth=2)
longCondition = ta.crossover(price1, price2)
if longCondition
strategy.entry('Long', strategy.long)
shortCondition = ta.crossunder(price1, price2)
if shortCondition
strategy.entry('Short', strategy.short)