週末のスイングトレード戦略


作成日: 2023-11-16 10:53:01 最終変更日: 2023-11-16 10:53:01
コピー: 0 クリック数: 601
1
フォロー
1617
フォロワー

週末のスイングトレード戦略

概要

この戦略は,金曜日の閉盘価格に基づいて長ポジションと空ポジションの入場条件を設定し,土曜日と日曜日の開盤時に多額の空白を行い,月曜日の開盤前に平ポジションを行う.この戦略は,金曜日の閉盘価格の近くの価格変動をキャプチャすることによって利益を上げる.

原則

  1. 金曜日の閉店価格を基準価格として記録する
  2. 営業時間:土曜日,日曜日
    • 価格が金曜日の閉店価格の4.5%以上なら,空白
    • 価格が金曜日の閉店価格の4.5%を下回った場合,さらに多くする.
  3. ストップは初期資金の3%に設定します.
  4. 月曜の営業前は,すべてのポジションをクリアする.

優位分析

  1. 市場リスクを低減するために,土曜日と日曜日の低取引量による価格変動を利用する
  2. 明確な入場・出場条件により,戦略の実施が困難になる
  3. ショートライン操作,安定した小利益を追求
  4. 資金の回転が速い

リスク分析

  1. 予想より低い価格変動で,土曜日と日曜日はポジションの開設ができない.
  2. 波動が多すぎると止損
  3. 月曜日の重大事件により,価格が上昇し,損失を止めることができませんでした.

リスク対策:

  1. 入学条件の変動幅を調整する
  2. ストップポイントを合理的に設定する
  3. 週末に持たないように

最適化の方向

  1. 各種の特性を考慮して入場幅を調整する
  2. 回測結果に基づいて止条件の最適化
  3. 資金の規模によって異なるレバレッジを選択する
  4. 均線指数フィルタリングを組み合わせた入場時刻

要約する

この戦略は,ショートラインの取引戦略として,非常に明確な取引論理とリスク制御措置を有する.合理的なパラメータ設定と継続的なテストによる最適化により,安定した投資収益を得ることができる.また,未週価格の過大波動によって引き起こされる損失のリスクにも注意する必要がある.リスク管理によって損失を制御する.

ストラテジーソースコード
/*backtest
start: 2023-10-16 00:00:00
end: 2023-11-15 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
//Copyright Boris Kozak 
strategy("XBT Weekend Trade Strategy", overlay=true, default_qty_type=strategy.percent_of_equity,initial_capital=20000)
leverage = input(1,"Leverage")
profitTakingPercentThreshold = input(0.03,"Profit Taking Percent Threshold")

//****Code used for setting up backtesting.****///
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(12, "Backtest Start Month")
testStartDay = input(10, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2025, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FFFF : na
bgcolor(testPeriodBackgroundColor, transp=50)

testPeriod() => true
    
//****END Code used for setting up backtesting.****///


//*** Main entry point is here***//
// Figure out how many days since the Friday close 
days_since_friday = if dayofweek == 6
    0
else 
    if dayofweek == 7
        1
    else
        if dayofweek == 1
            2
        else
            if dayofweek == 2
                3
            else
                if dayofweek == 3
                    4
                else
                    if dayofweek == 4
                        5
                    else
                        6
    
// Grab the Friday close price
fridaycloseprice = request.security(syminfo.tickerid,'D',close[days_since_friday])
plot(fridaycloseprice)
strategy.initial_capital = 50000
// Only perform backtesting during the window specified 
if testPeriod()
    // If we've reached out profit threshold, exit all positions 
    if ((strategy.openprofit/strategy.initial_capital) > profitTakingPercentThreshold)
        strategy.close_all()
    // Only execute this trade on saturday and sunday (UTC)
    if (dayofweek == 7.0 or dayofweek == 1.0)
        // Begin - Empty position (no active trades)
        if (strategy.position_size == 0)
            // If current close price > threshold, go short 
            if ((close>fridaycloseprice*1.045))
                strategy.entry("Short Entry", strategy.short, leverage)
            else
                // If current close price < threshold, go long
                if (close<(fridaycloseprice*0.955))
                    strategy.entry("Long Entry",strategy.long, leverage)
        // Begin - we already have a position
        if (abs(strategy.position_size) > 0)
            // We are short 
            if (strategy.position_size < 0)
                if ((close>strategy.position_avg_price*1.045))
                    // Add to the position
                    strategy.entry("Adding to Short Entry", strategy.short, leverage)
            else
                strategy.entry("Long Entry",strategy.long,leverage)
    // On Monday, if we have any open positions, close them 
    if (dayofweek==2.0)
        strategy.close_all()