
この戦略は,2つの異なる周期の移動平均 ((MA) を使用して取引信号を生成する.短期MAが下から上へと長期MAを横切ると,買入信号を生成する.短期MAが上から下へと長期MAを横切ると,売出信号を生成する.この戦略の主な考え方は,MAのトレンド追跡特性を利用して,MAの交差によってトレンドの転換を捕捉し,取引を行うことである.
双均線交差策略は,2つの異なる周期MAの交差によってトレンドの転換を捉える簡単な使いやすいトレンド追跡策策である.この戦略の優点は,論理的に明確で,信号が明確で,トレンド市場に適用される.しかし,揺れ動いている市場で,この戦略は,偽の信号と損失の取引を多く生み出す可能性があります.したがって,実際のアプリケーションでは,トレンドフィルタリング,ストップ・ストップ・損失の最適化,動向参数最適化,および他のシグナルとの組み合わせなどの方法で戦略のパフォーマンスを改善し,その適応性と安定性を向上させることができます.
/*backtest
start: 2023-05-22 00:00:00
end: 2024-05-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Combined Strategy", overlay=true)
// Moving Averages Length Inputs
short_length = input.int(20, "Short MA Length")
long_length = input.int(50, "Long MA Length")
// Moving Averages
ma_short = ta.sma(close, short_length)
ma_long = ta.sma(close, long_length)
// Buy Condition (Moving Average Crossover)
buy_condition = ta.crossover(ma_short, ma_long)
plotshape(series=buy_condition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
// Sell Condition (Moving Average Crossover)
sell_condition = ta.crossunder(ma_short, ma_long)
plotshape(series=sell_condition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
// Strategy Entry and Exit
if (buy_condition)
strategy.entry("Buy", strategy.long)
if (sell_condition)
strategy.entry("Sell", strategy.short)
// Debug statements
if (buy_condition)
label.new(x=bar_index, y=low, text="Buy Signal", color=color.green, style=label.style_label_up)
if (sell_condition)
label.new(x=bar_index, y=high, text="Sell Signal", color=color.red, style=label.style_label_down)