
快速移動平均線交差策略は,簡単な移動平均策略である.それは,2つの移動平均線を使用し,速くゆっくり,高速移動平均線が,下からゆっくり移動平均線を横切るとき,価格が上昇する可能性を示し,高速移動平均線が上から下にゆっくり移動平均線を横切るとき,価格が低下する可能性を示し,平衡する.これは将来の価格行動を予測する指標として使用できます.
この戦略は,2つの移動平均を使用し,速いと遅いである.具体的には,高速移動平均の長さは25サイクルをデフォルトし,遅い移動平均の長さは62サイクルをデフォルトする.戦略は,SMA,EMA,WMA,RMA,VWMAを含む異なるタイプの移動平均を選択することを許可する.
急速移動平均線が,下からゆっくり移動平均線を横断すると,短期価格が長期価格を突破し始めることを示す,典型的な金交差信号であり,価格が上昇チャネルに入ると予測される,このとき戦略は多; 急速移動平均線が,上から下からゆっくり移動平均線を横断すると,短期価格が長期価格を突破し始めることを示す,死亡交差信号であり,価格が下降チャネルに入ると予測される,このとき戦略は平仓である.
このように,平均線の交差によって,価格の傾向と方向を判断し,それに応じて多かれ少なかれ平仓を取って,利益を得ることができる.
この戦略の利点は以下の通りです.
全体として,この戦略は,急激な平均線交差を核心取引信号として使用し,価格の将来の傾向を判断する能力が強く,トレンド追跡の優位性に基づいて,良い利益を得ることができ,実戦での適用に値する.
この戦略にはいくつかの潜在的リスクがあります.
これらのリスクは,以下の方法で制御および改善できます.
この戦略の改善策は以下の通りです.
急速平均線と遅速平均線の周期選択:現在のデフォルトパラメータは最適ではないかもしれない.異なる周期パラメータを試して最適の配置を見つけることができます.
移動平均のタイプを選択:特定の品種にどのタイプが最適かをテストするために,複数の移動平均が現在提供されています.
他の指標または戦略との組み合わせ:波動率指標,量値指標,またはトレンド追跡戦略との組み合わせを試して効果を上げることができます.
パラメータの自己適応最適化:平均周期のパラメータを市場の変動率と流動性に応じて自動的に調整して安定性を高める
AIモデル支援:機械学習アルゴリズムを使用して大量のデータを分析し,最適の取引ルールを自動的に探す
これらの最適化手段によって,戦略の収益性や安定性をさらに向上させることが期待されます.
快速平均線交差策は全体的に非常に実用的なトレンド追跡策である. それは,価格の異なる時間尺度での変化の法則を把握し,快速平均線を突破し,遅い平均線を突破して,価格の将来の可能性のある傾向と方向を判断する. 策略の構想は,単純で明快で,容易に理解し,実行し,パラメータをカスタマイズできる柔軟性があり,同時に信頼性が高く,自動化が高度で,適用範囲は広大で,拡張性が強い. もちろん,一定の誤報リスクがあり,最大限の効果を出すために他の指標と組み合わせて使用する必要がある.
/*backtest
start: 2023-02-20 00:00:00
end: 2024-02-26 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
//Author @divonn1994
initial_balance = 100
strategy(title='Fast v Slow Moving Averages Strategy', shorttitle = 'Fast v Slow', overlay=true, pyramiding=0, default_qty_value=100, default_qty_type=strategy.percent_of_equity, precision=7, currency=currency.USD, commission_value=0.1, commission_type=strategy.commission.percent, initial_capital=initial_balance)
//Input for number of bars for moving average, Switch to choose moving average type, Display Options and Time Frame of trading----------------------------------------------------------------
fastBars = input.int(25, "Fast moving average length", minval=1)
slowBars = input.int(62, "Slow moving average length", minval=1)
strategy = input.string("EMA", "MA type", options = ["EMA", "VWMA", "SMA", "RMA", "WMA"])
redOn = input.string("On", "Red Background Color On/Off", options = ["On", "Off"], group='Display')
greenOn = input.string("On", "Green Background Color On/Off", options = ["On", "Off"], group='Display')
maOn = input.string("On", "Moving Average Plot On/Off", options = ["On", "Off"], group='Display')
startMonth = input.int(title='Start Month 1-12 (set any start time to 0 for furthest date)', defval=1, minval=0, maxval=12, group='Beginning of Strategy')
startDate = input.int(title='Start Date 1-31 (set any start time to 0 for furthest date)', defval=1, minval=0, maxval=31, group='Beginning of Strategy')
startYear = input.int(title='Start Year 2000-2100 (set any start time to 0 for furthest date)', defval=2011, minval=2000, maxval=2100, group='Beginning of Strategy')
endMonth = input.int(title='End Month 1-12 (set any end time to 0 for today\'s date)', defval=0, minval=0, maxval=12, group='End of Strategy')
endDate = input.int(title='End Date 1-31 (set any end time to 0 for today\'s date)', defval=0, minval=0, maxval=31, group='End of Strategy')
endYear = input.int(title='End Year 2000-2100 (set any end time to 0 for today\'s date)', defval=0, minval=0, maxval=2100, group='End of Strategy')
//Strategy Calculations-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
inDateRange = true
maMomentum = switch strategy
"EMA" => (ta.ema(close, fastBars) >= ta.ema(close, slowBars)) ? 1 : -1
"SMA" => (ta.sma(close, fastBars) >= ta.sma(close, slowBars)) ? 1 : -1
"RMA" => (ta.rma(close, fastBars) >= ta.rma(close, slowBars)) ? 1 : -1
"WMA" => (ta.wma(close, fastBars) >= ta.wma(close, slowBars)) ? 1 : -1
"VWMA" => (ta.vwma(close, fastBars) >= ta.vwma(close, slowBars)) ? 1 : -1
=>
runtime.error("No matching MA type found.")
float(na)
fastMA = switch strategy
"EMA" => ta.ema(close, fastBars)
"SMA" => ta.sma(close, fastBars)
"RMA" => ta.rma(close, fastBars)
"WMA" => ta.wma(close, fastBars)
"VWMA" => ta.vwma(close, fastBars)
=>
runtime.error("No matching MA type found.")
float(na)
slowMA = switch strategy
"EMA" => ta.ema(close, slowBars)
"SMA" => ta.sma(close, slowBars)
"RMA" => ta.rma(close, slowBars)
"WMA" => ta.wma(close, slowBars)
"VWMA" => ta.vwma(close, slowBars)
=>
runtime.error("No matching MA type found.")
float(na)
//Enter or Exit Positions--------------------------------------------------------------------------------------------------------------------------------------------------------------------
if ta.crossover(maMomentum, 0)
if inDateRange
strategy.entry('long', strategy.long, comment='long')
if ta.crossunder(maMomentum, 0)
if inDateRange
strategy.close('long')
//Plot Strategy Behavior---------------------------------------------------------------------------------------------------------------------------------------------------------------------
plot(series = maOn == "On" ? fastMA : na, title = "Fast Moving Average", color = color.new(color.white,0), linewidth=2, offset=1)
plot(series = maOn == "On" ? slowMA : na, title = "Slow Moving Average", color = color.new(color.purple,0), linewidth=3, offset=1)
bgcolor(color = inDateRange and (greenOn == "On") and maMomentum > 0 ? color.new(color.green,75) : inDateRange and (redOn == "On") and maMomentum <= 0 ? color.new(color.red,75) : na, offset=1)