レインボー・ムービング・平均取引戦略

作者: リン・ハーンチャオチャン, 日付: 2023-09-28 11:01:59
タグ:

概要

レインボー・ムービング・アベレア取引戦略は,レインボー・ムービング・アベレア指標に基づいて設計されています.この戦略は,7つの移動平均を持つレインボー・ムービング・アベレアシステムを通じてトレンド方向を特定し,低リスクエントリーを達成するためにRSI指標で偽信号をフィルタリングします.

戦略の論理

戦略は次のステップで取引信号を生成します

  1. 虹の移動平均システムを構築する. 7つの移動平均が含まれます. 最初の移動平均は12の期間を持ち,閉値をソースデータとして使用します.他の6つの移動平均は,前の移動平均をソースとして,3の漸進的に減少する期間を持っています.

  2. トレンド方向を決定します.最初の移動平均が虹の上部にある場合,それを上昇傾向として定義します.それが下部にある場合,それを下落傾向として定義します.それが真ん中にある場合,それを統合として定義します.

  3. シグナルを生成する.トレンドが上昇傾向から下落傾向に変化すると,セールシグナルが生成される.トレンドがダウントレンドから上昇傾向に変化すると,購入シグナルが生成される.トレンドが統合から上昇傾向または下落傾向に変化すると,既存のポジションを閉じる.

  4. RSIフィルター.RSIが正常状態を示すときのみシグナルを受け入れます.最初のRSIは誤ったブレイクを避けるために過買いと過売りゾーンの間でなければなりません.第2のRSIは強い勢いを確保するために中間ゾーンの外でなければなりません.

利点

この戦略の利点は以下の通りです.

  1. 虹の移動平均システムでは,トレンドの方向を正確に識別します.複数の移動平均値が組み合わせて,市場の騒音とスポットトレンドの逆転をフィルタリングします.

  2. 二重RSIフィルタメカニズムは,誤ったブレイクシグナルと罠に巻き込まれることを効果的に回避する.最初のRSIは正常領域であることを保証し,第2のRSIは十分な強い勢いを保証する.

  3. トレンドと逆転指標を組み合わせることで,トレンド逆転時にタイムリーエントリーが可能になり,勢いを追うことは避けられます.

  4. 整合中にアクティブポジションを閉じることは,レンジ・バインド市場のリスクを回避する.

  5. この戦略は,より良い結果を得るため,異なる製品とタイムフレームに調整できる大きなパラメータ最適化スペースを提供しています.

リスク

この戦略の主なリスクは

  1. 不明なトレンド逆転は誤った信号を生み,損失を引き起こす可能性があります.移動平均期を調整することで逆転信号がより明確になります.

  2. 長期 konsolidiation の間,頻繁な開閉はコストと滑り幅を増加させる. RSI パラメータを最適化することで, konsolidiation のフィルタリングを強化することができる.

  3. 遅延した逆転は,最初の信号後の損失を拡大します.移動平均期間の差が増加すると,信号がよりタイムリーになります.

  4. 間違ったパラメータ設定は,正しい信号をフィルタリングしたり,信号の遅延を引き起こす可能性があります.パラメータは製品文字ごとに調整する必要があります.

オプティマイゼーションの方向性

戦略は以下の側面で最適化できます.

  1. 移動平均パラメータの最適化,期間長さ,期間比,MAタイプなどを含む傾向判断をより正確にする.

  2. RSI パラメータの最適化,フィルタリングをより正確にするために,期間,過買い/過売りレベル,中立ゾーンなどを含む.

  3. 最適な時間枠を見つけるため

  4. 製品最適化,パラメータとルールを調整し,異なる製品に最適化します

  5. リスクと利益の大きさを制御するためにストップ・ロストと 利益を取ることを追加します

結論

レインボー・ムービング・アベア・トレード戦略は,トレンド決定とシグナルフィルタリングを組み合わせて,逆転信号を効果的に捕捉する.正確な判断と制御可能なリスクにより,この戦略はパラメータ調整と論理精製後に非常に実用化することができます.全体として,深層の研究と適用に値します.


/*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"}]
*/

//╔════════════════════════════════════════════════════════════════════════════╗
//║Rainbow Backtesting base on "Rainbow Moving Average" Strategy as below:     ║
//║1.Rainbow Moving Average setup                                              ║
//║- Source: source of 1st MA                                                  ║
//║- Type: SMA/EMA                                                             ║
//║- Period: period of 1st MA                                                  ║
//║- Displacement: period of 2nd MA to 7th MA with source is previous MA       ║
//║2.Trend Define                                                              ║
//║- Up Trend: Main MA moving at the top of Rainbow                            ║
//║- Down Trend: Main MA moving at the bottom of Rainbow                       ║
//║- Sideway: Main MA moving between the top and the bottom of Rainbow         ║
//║3.Signal                                                                    ║
//║- Buy Signal: When Rainbow change to Up Trend.                              ║
//║- Sell Signal: When Rainbow change to Down Trend.                           ║
//║- Exit: When Rainbow change to Sideway.                                     ║
//║4.RSI Filter                                                                ║
//║- "Enable": Only signals have 1st RSI moving between Overbought and Oversold║
//║and 2nd RSI moving outside Middle Channel are accepted.                     ║
//║- The filter may help trader avoid bull trap, bear trap and choppy market.  ║
//╚════════════════════════════════════════════════════════════════════════════╝

//@version=4
strategy("Rainbow Strategy Backtesting",overlay=false)
//++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++ Rainbow Moving Average +++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++
rainbow_tt="=== Rainbow Moving Average ==="
ma1_source=input(hlc3,title="Source",type=input.source, inline="set1", group=rainbow_tt)
rb_type=input("SMA",title="Type",options=["SMA","EMA"], inline="set1", group=rainbow_tt)
ma1_len=input(12,title="Period", inline="set2", group=rainbow_tt)
dis_len=input(3,title="Displacement", inline="set2", group=rainbow_tt,minval=2)
trend_tt="=== Trend Color ==="
up_col=input(color.new(color.blue,0),title="Up",inline="Color",group=trend_tt)
dn_col=input(color.new(color.red,0),title="Down",inline="Color",group=trend_tt)
sw_col=input(color.new(color.yellow,0),title="No",inline="Color",group=trend_tt)
//1st
ma1=rb_type=="SMA"?sma(ma1_source,ma1_len):ema(ma1_source,ma1_len)
//2nd
ma2=rb_type=="SMA"?sma(ma1,dis_len):ema(ma1,dis_len)
//3rd
ma3=rb_type=="SMA"?sma(ma2,dis_len):ema(ma2,dis_len)
//4
ma4=rb_type=="SMA"?sma(ma3,dis_len):ema(ma3,dis_len)
//5
ma5=rb_type=="SMA"?sma(ma4,dis_len):ema(ma4,dis_len)
//6
ma6=rb_type=="SMA"?sma(ma5,dis_len):ema(ma5,dis_len)
//7
ma7=rb_type=="SMA"?sma(ma6,dis_len):ema(ma6,dis_len)
//MinMax
rb_max=max(ma1,ma2,ma3,ma4,ma5,ma6,ma7)
rb_min=min(ma1,ma2,ma3,ma4,ma5,ma6,ma7)
dir_col=
       ma1==rb_max?up_col:
       ma1==rb_min?dn_col:
       sw_col
dir_style=shape.circle
plotshape(dir_col[1]==dir_col?0:na,title="Trend",style=dir_style,color=dir_col,location=location.absolute)
//++++++++++++++++++++++++++++++++++++++
//+++++++++++++ RSI Filter +++++++++++++
//++++++++++++++++++++++++++++++++++++++
rsi_tt="=== RSI Filter ==="
rsi_filter=input("Enable",title="Filter",options=["Enable","Disable"],inline="set",group=rsi_tt)
over_tt="Over Filter"
rsi_len_1=input(12,title="Period",inline="set",group=over_tt)
rsi_ovb=input(65,title="Overbought",inline="set",group=over_tt)
rsi_ovs=input(35,title="Oversold",inline="set",group=over_tt)
rsi_1=rsi(close,rsi_len_1)
mid_tt="Middle Filter"
rsi_len_2=input(9,title="Period",inline="set",group=mid_tt)
rsi_mid_top=input(56,title="Upper",inline="set",group=mid_tt)
rsi_mid_bot=input(44,title="Lower",inline="set",group=mid_tt)
rsi_2=rsi(close,rsi_len_2)
//Status
var rsi_status="None"
if (rsi_1>rsi_ovs and rsi_1<rsi_ovb) and (rsi_2[1]<rsi_mid_bot or rsi_2[1]>rsi_mid_top)
    rsi_status:="Normal"
else
    rsi_status:="None"
//Signal
BuySignal= 
       rsi_filter=="Disable"?
       dir_col[1]!=up_col
       and
       dir_col[0]==up_col
       :
       dir_col[1]!=up_col
       and
       dir_col[0]==up_col
       and
       rsi_status=="Normal"
       
SellSignal= 
       rsi_filter=="Disable"?
       dir_col[1]!=dn_col
       and
       dir_col[0]==dn_col
       :
       dir_col[1]!=dn_col
       and
       dir_col[0]==dn_col
       and
       rsi_status=="Normal"
       
exit=
       (dir_col[1]!=sw_col
       and
       dir_col[0]==sw_col)
buycol =
       BuySignal?
       up_col: na

sellcol =
       SellSignal?
       dn_col: na

exitcol =
       exit?
       sw_col: na

buy_style=shape.arrowup
sell_style=shape.arrowdown
exit_style=shape.square
plotshape(BuySignal?0:na,title="Buy",text="Buy",style=buy_style,color=buycol,location=location.absolute)
plotshape(SellSignal?0:na,title="Sell",text="Sell",style=sell_style,color=sellcol,location=location.absolute)
plotshape(exit?0:na,title="Exit",text="Exit",style=exit_style,color=exitcol,location=location.absolute)

filter=
       rsi_filter=="Enable"?
       dir_col[1]!=dir_col 
       and BuySignal==false 
       and SellSignal==false 
       and exit==false:
       na
filter_style=shape.xcross
filtercol=
       filter?
       dir_col:na
plotshape(filter?0:na,title="Filter",text="Filter",style=filter_style,color=filtercol,location=location.absolute)

//+++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++ Backtesting ++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++
strategy.entry("Long", strategy.long, when=BuySignal)
strategy.close("Long", when=exit or filter)
strategy.entry("Short", strategy.short, when=SellSignal)
strategy.close("Short", when=exit or filter)
//EOF

もっと