三重移動平均の交差システムは,典型的なトレンドを追跡する株式取引戦略である.それは,3つの異なる時間長さの移動平均の交差を買入と売却の信号として使用する.短期移動平均が中期移動平均を横切って,中期移動平均が長期移動平均を横切って買入の信号を生じるとき;短期移動平均が中期移動平均を横切って,中期移動平均が長期移動平均を横切って,中期移動平均が長期移動平均を横切って販売の信号を生じるとき.
この戦略は,3つの移動平均に基づいており,長期移動平均ma1,中期移動平均ma2,短期移動平均ma3である.
length1 = input(18,'长线')
length2 = input(9,'中线')
length3 = input(4,'短线')
ma1 := sma(close,length1)
ma2 := sma(close,length2)
ma3 := sma(close,length3)
その中で,length1,length2およびlength3はそれぞれ3つの移動平均の時間長さを定義する.sma関数は,対応する長さの単純な移動平均を計算する.
買いと売却のタイミングを判断するために,3つの移動平均の交差値を使用します.
if ma2 > ma1 and ma3 > ma3[1]
strategy.entry("Long", strategy.long)
if ma2 < ma1 and ma3 < ma3[1]
strategy.entry("Short", strategy.short)
中期線ma2で長期線ma1を穿過し,短期線ma3で前回の周期ma3を穿過すると,多信号を発する.中期線ma2の下で長期線ma1を穿過し,短期線ma3の下で前回の周期ma3を穿過すると,空信号を発する.
これらのリスクは,適切な最適化パラメータと,他の指標をフィルター条件として組み合わせることで軽減できます.
三重移動平均線交差策略は,シンプルで実用的なトレンド追跡策略である.それは,3つの移動平均線を交差して市場動向の変化を判断して取引信号を生成する.この策略の利点は,規則がシンプルで,トレンドを効果的に追跡でき,中長期線操作に適していることである.しかし,ある種の偽信号リスクと撤回リスクもある.パラメータ最適化,補助指標の加入などの方法によって,異なる市場環境に適応するために改めることができる.全体的に言えば,三重移動平均線交差策は,取引量化のための基本的な入口策であり,取引アルゴリズムを学ぶための良いスタートである.
/*backtest
start: 2023-08-28 00:00:00
end: 2023-09-27 00:00:00
period: 2h
basePeriod: 15m
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/
// © dongyun
//@version=4
strategy("三重交叉修正模式系统", overlay=true)
//strategy.risk.allow_entry_in(strategy.direction.long)
length1 = input(18,'长线')
length2 = input(9,'中线')
length3 = input(4,'短线')
ma1 =0.0
ma2 = 0.0
ma3 = 0.0
ma1 := sma(close,length1)
ma2 := sma(close,length2)
ma3 := sma(close,length3)
plot(ma1)
plot(ma2)
plot(ma3)
if ma2 > ma1 and ma3 > ma3[1]
strategy.entry("Long", strategy.long, when=strategy.position_size <= 0)
if ma2 < ma1 and ma3 < ma3[1]
strategy.entry("Short", strategy.short, when=strategy.position_size > 0)