この戦略は,3つの移動平均の金叉死叉形式に基づいて取引されます. 急速移動平均線上を中速線と中速線上を遅速線を横切るときは多行し,急速移動平均線下を中速線と中速線下を遅速線を横切るときは空行します.
具体的には,この戦略は,3つの異なる周期の移動平均線間の交差を利用して取引する. 急速線は現在の短期トレンドを表し,中速線は中期トレンドを表し,遅い線は長期トレンドを表す. 短中長期の3つの均等線が順番に上昇して交差すると,トレンドが開始され,多額の取引が行われ,下方交差すると,トレンドが逆転し,空白となる.
ポジション保持時間を調整し,平均線パラメータを最適化し,ストップ・ロスの戦略を導入することによってリスクを管理することができます.
この戦略は,三均線交差判定の傾向方向に基づいてポジションを保持する. 取引信号が単純で明確で,構成性が強であることの利点; 欠点は,遅滞が容易で,パラメータの最適化が必要である. パラメータの最適化,停止損失戦略などの効果を向上させ,撤回リスクを制御することができる. この戦略は,トレーダーが移動平均の適用と多均線交差の取引理念を習得するのを助ける.
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// © DaynTrading
//@version=4
// strategy(
// title="Simple Moving Average Cross",
// overlay=true,
// initial_capital=5000,
// default_qty_type=strategy.percent_of_equity,
// default_qty_value=2,
// commission_type=strategy.commission.percent,
// commission_value=0.075,
// pyramiding=0
// )
sma_top_input = input(title="SMA Top", type=input.integer, defval=20)
sma_mid_input = input(title="SMA Mid", type=input.integer, defval=50)
sma_low_input = input(title="SMA Low", type=input.integer, defval=200)
bars_long = input(title="Long: After trigger, how many bars to wait?", type=input.integer, defval=5)
bars_short = input(title="Short: After trigger, how many bars to wait?", type=input.integer, defval=5)
sma_top = sma(close, sma_top_input)
sma_mid = sma(close, sma_mid_input)
sma_low = sma(close, sma_low_input)
long = sma_top > sma_mid and sma_mid > sma_low
short = sma_top < sma_mid and sma_mid < sma_low
long_condition = long and long[bars_long] and not long[bars_long + 1]
short_condition = short and short[bars_short] and not short[bars_short + 1]
close_long = sma_top < sma_mid and sma_mid < sma_low and not long[bars_long + 1]
close_short = sma_top > sma_mid and sma_mid > sma_low and not short[bars_short + 1]
plot(sma_top, title="SMA Top", color=#95f252, linewidth=2)
plot(sma_mid, title="SMA Mid", color=#FF1493, linewidth=2)
plot(sma_low, title="SMA Low", color=#6a0dad, linewidth=2)
strategy.entry("LongPosition", strategy.long, when = long_condition)
strategy.entry("ShortPosition", strategy.short, when = short_condition)
strategy.close("LongPosition", when = close_short)
strategy.close("ShortPosition", when = close_long)