双動平均スーパートレンド量的な取引戦略

作者: リン・ハーンチャオチャン開催日:2024-02-05 12:05:10
タグ:

img

概要

この戦略は,二重移動平均値とスーパートレンド指標を組み合わせて,取引信号を構築し,高い収益性を達成するために,異なるサイクル組み合わせを通じてトレンド方向を判断します.

原則

この戦略は,MACDとスーパートレンド指標を使用して市場へのエントリータイミングを決定します.MACDのダブル移動平均は短期トレンド方向を決定し,スーパートレンドは中長期トレンド方向を決定します.

速線がスローラインを上向きに突破すると,それは買い信号である.この時点で,中長期スーパートレンドも上向きのトレンドである場合,最終的な買い信号はロングに行くために生成される.逆に,速線がスローラインを下向きに突破すると,それは売り信号である.この時点で,中長期スーパートレンドも下向きのトレンドである場合,最終的な売り信号はショートに行くために生成される.

ストップ・ロストとテイク・プロフィートは固定値に設定されています

利点分析

この戦略の最大の利点は,市場指向を決定するためにダブル移動平均とスーパートレンドの両方を使用し,中短期および中長期分析を組み合わせて意思決定効率を大幅に向上させ,誤ったブレイクアウトを回避することです.また,スーパートレンドは,市場変動に応じてパラメータを調整し,より幅広い市場環境に適応することができます.

リスク分析

この戦略の主なリスクは,固定ストップ損失と取利益設定がより大きな利益機会を逃す可能性があることです. さらに,中短期と中長期の判断が異なる場合,戦略は適切に機能しません.浮動ストップ損失と取利益設定によってこのリスクを軽減することができます.

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

この戦略は,次の側面で最適化できます.

  1. ストップ・ロスのダイナミックな調整メカニズムを増やし,ストップ・ロスの設定と市場変動とトレンドに応じて利益を引き出す.

  2. MACD パラメータを最適化して,目標多様性に適した移動平均 パラメータを見つけます.

  3. スーパートレンドのパラメータを最適化して 市場への敏感性を調整する

  4. 判断のための他の指標を増やして より多次元的な信号を提供し 戦略のパフォーマンスを向上させる.

概要

この戦略は,二重移動平均値とスーパートレンド指標の利点を成功裏に組み合わせています.異なるサイクル判断を組み合わせることで,間違った信号をフィルタリングし,トレンド市場でより良い収益を得ることができます.パラメータ最適化とメカニズム調整を通じて,この戦略の安定性と収益性をさらに高めることができます.


/*backtest
start: 2024-01-28 00:00:00
end: 2024-02-04 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
//Supertrend Strategy by breizh29 using *rajandran.r* Supertrend Indicator

strategy("Super Trend 2 MACD", overlay=true)
// MACD input
source = input(close)
fastLength = input(12, minval=1, title="MACD fast moving average")
slowLength=input(26,minval=1, title="MACD slow moving average")
signalLength=input(9,minval=1, title="MACD signal line moving average")

// Calculation
fastMA = sma(source, fastLength)
slowMA = sma(source, slowLength)

Macd = fastMA - slowMA
Signal = sma(Macd, signalLength)


res = input(title="Main SuperTrend Time Frame",  defval="120")
Factor=input(1, minval=1,maxval = 100)
Pd=input(1, minval=1,maxval = 100)

tp = input(500,title="Take Profit")
sl = input(400,title="Stop Loss")


Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
MUp=request.security(syminfo.tickerid,res,hl2-(Factor*atr(Pd)))
MDn=request.security(syminfo.tickerid,res,hl2+(Factor*atr(Pd)))

Mclose=request.security(syminfo.tickerid,res,close)

TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn

MTrendUp=Mclose[1]>MTrendUp[1]? max(MUp,MTrendUp[1]) : MUp
MTrendDown=Mclose[1]<MTrendDown[1]? min(MDn,MTrendDown[1]) : MDn

Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown

MTrend = Mclose > MTrendDown[1] ? 1: Mclose< MTrendUp[1]? -1: nz(MTrend[1],1)
MTsl = MTrend==1? MTrendUp: MTrendDown

linecolor = Trend == 1 ? green : red
plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "SuperTrend")

Mlinecolor = MTrend == 1 ? blue : orange
plot(MTsl, color = Mlinecolor , style = line , linewidth = 2,title = "Main SuperTrend")

plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", shape.triangleup,location.belowbar,green,0,0)
plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)

up = Trend == 1 and Trend[1] == -1 and MTrend == 1 
down = Trend == -1 and Trend[1] == 1 and MTrend == -1 
plotarrow(up ? Trend : na, title="Up Entry Arrow", colorup=lime, maxheight=60, minheight=50, transp=0)
plotarrow(down ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=60, minheight=50, transp=0)


golong = Trend == 1 and Trend[1] == -1 and MTrend == 1 and Macd > Signal
goshort = Trend == -1 and Trend[1] == 1 and MTrend == -1 and Macd < Signal

strategy.entry("Buy", strategy.long,when=golong)
strategy.exit("Close Buy","Buy",profit=tp,loss=sl)
   
   
strategy.entry("Sell", strategy.short,when=goshort)
strategy.exit("Close Sell","Sell",profit=tp,loss=sl)


もっと