双動平均クロスオーバー・イントラデイ・フューチャー取引戦略

作者: リン・ハーンチャオチャン開催日:2023年11月15日 16時48分02秒
タグ:

img

概要

この戦略は,二重移動平均クロスオーバーの原則を利用し,ストップ・ロストとテイク・プロフィートのATR指標を組み込み,先物契約に適した日中取引戦略を設計するために取引時間制御を追加しています.この戦略はシンプルで理解しやすいため,初心者にとって理想的です.

戦略の論理

この戦略は,エントリーシグナルとして5期および20期WMAラインのクロスオーバーを使用する. 5期線が20期線を超えると長くなり,5期線が20期線を下回ると短くなります.また,トレンド方向を決定するために50期WMAラインを使用します.価格のブレイク方向が主要なトレンドと一致するときにのみ取引シグナルが起動されます.

さらに,戦略は動的なストップ損失と利益のレベルを設定するためにATR指標を活用する.ATRは市場の変動を反映する.戦略は,ストップ損失と利益の決定のためにATR値を因数 (例えば3) で掛けることで,取引損失を制御する.

最後に,この戦略は,誤った信号が容易に形成される市場開閉と閉閉の周りの高い変動を避けるために,米国の取引時間 (9:00〜14:30 CST) の間での取引のみを誘発します.

利点分析

この戦略には以下の利点があります.

  1. 二重移動平均のクロスオーバーは,適切なタイミングでトレンドのターニングポイントを効果的に把握します.

  2. トレンドフィルターは主要なトレンドに反する取引を避け,誤った信号を減らす.

  3. 動的ATRベースのストップ損失制御

  4. 取引時間を制限することで,不安定な開閉期が避けられます.

  5. シンプルで明快なルールで 初心者でも簡単に理解し実行できます

  6. MA 期間,ATR マルチプリキュア,取引時間など,最適化のためのカスタマイズ可能なパラメータ.

リスク分析

この戦略には次のリスクもあります

  1. ストップ・ロスの引き金となるのは レンジ・バインド市場です

  2. 二重MAクロスオーバーは遅延し 短期的なブレイクアウトを逃す可能性があります

  3. ATRパラメータの設定が正しくない場合,大きなまたは小さなストップ損失が発生します.

  4. 基本分析なしで テクニカル指標だけに頼る

  5. 効果は適切なシンボルと時間枠に依存します

  6. メカニカル・システムでは 調整される危険性があります

  7. パラメーターは異なる取引セッションに調整する必要があります.

パラメータ調節,インジケータ組み合わせ,選択的な手動介入などによって改善できます

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

戦略は以下の側面で強化できる:

  1. EMA,DMAなど様々なMAシステムをテストします

  2. MACD,RSIなど他の技術フィルターを追加します.

  3. ATR パラメータを最適化して,ストップ・ロスト/利益の改善を図る

  4. 高品質の入力信号を見つけるために音量指標を組み込む.

  5. パラメータをシンボルの仕様に基づいて調整する

  6. 市場に反する取引を避けるために基本的な要素を統合する.

  7. 市場モデル化のために ニューラルネットワークのような 機械学習を導入します

  8. 複数の時間枠の組み合わせを探して より多くの機会を得てください

  9. 安定性を向上させるための戦略の組成

結論

概要すると,これは初心者がライブトレーディングを実践するのに適したシンプルで直感的な戦略です.同時に,より技術的な指標や機械学習を通じて最適化するための大きな余地が残っています.シンボルと市場動態に基づいたパラメータチューニングも重要です.この戦略は量子トレーディング初心者にとって基準フレームワークを提供し,安定した利益のために絶え間ないテストと強化が必要です.


/*backtest
start: 2023-10-15 00:00:00
end: 2023-11-14 00:00:00
period: 1h
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/
// © james4392010

//@version=4

strategy(title="DayTradingFutures Cross-Strategy", overlay=true)




// === GENERAL INPUTS ===
Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
//highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn



wmaFastSource   = input(defval = close, title = "Fast WMA Source")
wmaFastLength   = input(defval = 5, title = "Fast WMA Period")
wmaSlowSource   = input(defval = close, title = "Slow WMA Source")
wmaSlowLength   = input(defval = 20, title = "Slow WMA Period")
wmaDirectionSource  = input(defval = close, title = "Trend 50 Period Source")
wmaDirectionLength  = input(defval = 50, title = "Trend 50 Period")
timeinrange(res, sess) => time(res, sess) != 0



// === SERIES SETUP ===
/// a couple of ma's..
wmaFast = wma(close, 5)
wmaSlow = wma(close, 20)
wmaDirection = wma(close, 50)





// === PLOTTING ===
fast = plot(series=wmaFast, color=color.white, linewidth=2)
slow = plot(series=wmaSlow, color=color.yellow, linewidth=2)
direction = plot(series=wmaDirection, color=color.red, linewidth=2)


// === INPUT BACKTEST RANGE ===

//fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
//fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
//fromYear = input(defval = 2022, title = "From Year", minval = 2022)
 
// To Date Inputs
//toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
//toMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
//toYear = input(defval = 2022, title = "To Year", minval = 2022)
//startDate = timestamp(fromYear, fromMonth, fromDay)
//finishDate = timestamp(toYear, toMonth, toDay)
//inDateRange= (time >= fromDay, fromMonth, fromYear and time <= toDay, toMonth, toYear) 



// === FUNCTION EXAMPLE ===
//inDateRange = (time >= fromDay, fromMonth, fromYear) and (time <= toDay, toMonth, toYear)


// === LOGIC ===

enterLong = crossover(wmaFast, wmaSlow) and close > wmaDirection and timeinrange(timeframe.period, "0900-1430")
enterShort = crossunder(wmaFast, wmaSlow) and close < wmaDirection and timeinrange(timeframe.period, "0900-1430")

//trend := nz(trend[1], trend)
//trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
//upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)

buySignal = enterLong 
//plotshape(enterLong ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green)
plotshape(enterLong and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
//dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)

sellSignal = enterShort
//plotshape(enterShort ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red)
plotshape(enterShort and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
//mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
//longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
//shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
//fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
//fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="Buy", message="Buy!")
alertcondition(sellSignal, title="Sell", message="Sell!")
//changeCond = trend != trend[1]
//alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")



// Entry for strategy //

//tp=input(25,title="TakeProfit")
//sl=input(40,title="StopLoss")

strategy.entry("Long",1, when=buySignal)
//strategy.exit("Exit",profit=tp,loss=sl)
//strategy.exit("TakeProfit",profit=tp)
//strategy.exit("StopLoss",loss=sl)

strategy.entry("Short",1, when=sellSignal)
//strategy.exit("Exit",profit=tp,loss=sl)
//strategy.exit("TakeProfit",profit=tp)
//strategy.exit("StopLoss",loss=sl)
//strategy.exit("Exit", wmaFastwmaSlow)

//Buy and Sell Signals

//strategy.close_all(when =not timeinrange(timeframe.period, "1000-1430"))   


// === FILL ====

fill (fast, slow, color = wmaSlow > wmaDirection ? color.green : color.red)
//fill(when=enterLong, tp, color = color.new(color.green, 90), title = "Profit area")
//fill(when=enterLong, sl, color = color.new(color.red, 90), title = "Loss area")
//fill(when=enterShort, tp, color = color.new(color.green, 90), title = "Profit area")
//fill(when=enterShort, sl, color = color.new(color.red, 90), title = "Loss area")






もっと