価格ブレイクアウトの高値と安値の追跡戦略


作成日: 2023-12-22 12:59:43 最終変更日: 2023-12-22 12:59:43
コピー: 1 クリック数: 606
1
フォロー
1623
フォロワー

価格ブレイクアウトの高値と安値の追跡戦略

概要

突破高低戦略は,価格がK線を突破する前の高点または低点を追跡するトレンド追跡戦略である.それは,移動平均を組み合わせてトレンドの方向性を判断し,突破点で入場し,その後,ストップ・ロスを設定し,またはストップ・ロスを追跡して利益をロックする.

戦略原則

この戦略は,次の条件を考慮して,ポジションの開設と終了を決定します.

  1. K線が赤か緑か判断して,K線が上か下かを判断します.
  2. このK線が前K線の高点と低点を突破するかどうかを判断する
  3. 急速移動平均と遅い移動平均を使ってトレンドの方向を判断する
  4. 上方K線が前方下方K線の高点を突破すると,多めにします. 下方K線が前方上方K線の低点を突破すると,空いてください.
  5. 平仓条件は,止損または追跡止損トリガー;また,反転K線が発生した場合に即時止損を設定することもできます.

この戦略は同時に第二の反転K線判断と組み合わせて偽突破をフィルターし,突破信号の信頼性を確保する.

優位分析

  • 戦略が明確で,突破操作は簡単
  • 移動平均の2つを組み合わせると,大きなトレンドを正しく判断できます.
  • ストップ・ロスを追跡することで,より多くの利益を得ることができます.
  • 逆K線メカニズムは,追いつくのを避けるのに役立ちます.

リスク分析

  • 突破失敗は超短線操作の損失を招く
  • 震災時の偽突破のリスクが高い
  • 双動平均は判断の誤差を招く可能性が高い

リスク管理措置:

  1. インデックスや大手指数で選択し,個々の株の高リスクを避ける
  2. 移動平均のパラメータを最適化し,判断の正確性を向上させる
  3. 単一損失のコントロールを確実にするため,適正にストップ幅を拡大する.

最適化の方向

この戦略は以下の点で最適化できます.

  1. 異なる移動平均の組み合わせをテストする
  2. テストは他の指標を組み合わせて判断する
  3. ポジション開設とストップポイントの最適化パラメータ
  4. 定量的に選抜するルールを増やし,質の高いものを選抜する
  5. 機械学習アルゴリズムと組み合わせたパラメータ自在化最適化

要約する

突破高低戦略は,全体的により成熟したトレンド追跡戦略であり,移動平均補助判断の下では,一定程度のトレンドを捕捉することができ,ストップ・ロズとストップ・ロズを追跡するメカニズムも利益をロックするのに役立ちます.継続的なテストと最適化により,この戦略のパラメータ設定と効果をさらに優れたものにすることができます.

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

//@version=5
strategy("Broken High/Low Strategy", overlay=true, initial_capital = 5000, default_qty_value = 25, pyramiding = 10, default_qty_type= strategy.percent_of_equity)

useEMAForStop = input.bool(false, 'Use trail stop EMA', group = 'Exit strategy')
trailStopMALength = input(8, 'Trail stop EMA length', group = 'Exit strategy')

fastMALength = input(5 , 'Fast MA length', group = 'Trend strength')
fastEMAEnabled = input.bool(false, 'Fast EMA enabled (default is SMA)', group = 'Trend strength')

slowMALength = input(10, 'Slow MA length', group = 'Trend strength')
slowEMAEnabled = input.bool(false, 'Slow EMA enabled (default is SMA)', group = 'Trend strength')

ignoreSlowMA = input.bool(false, 'Use fast MA for trend ignoring slow MA', group = 'Trend strength')

useOpposingBarAsExit = input.bool(false, 'Using opposing bar as exit', group = 'Exit strategy')
secondEntryEnabled = input.bool(false, 'Second bar that eliminates opposing bar for entry', group = 'Trend strength')

longsEnabled = input.bool(true, 'Enable longs', group = 'Trade settings')
shortsEnabled = input.bool(true, 'Enable shorts', group = 'Trade settings')

fastMA = fastEMAEnabled ? ta.ema(close, fastMALength) : ta.sma(close, fastMALength)
slowMA = slowEMAEnabled ? ta.ema(close, slowMALength) : ta.sma(close, slowMALength)

FromMonth=input.int(defval=1,title="FromMonth",minval=1,maxval=12, group = 'Time filters')
FromDay=input.int(defval=1,title="FromDay",minval=1,maxval=31, group = 'Time filters')
FromYear=input.int(defval=1990,title="FromYear",minval=1900, group = 'Time filters')
ToMonth=input.int(defval=1,title="ToMonth",minval=1,maxval=12, group = 'Time filters')
ToDay=input.int(defval=1,title="ToDay",minval=1,maxval=31, group = 'Time filters')
ToYear=input.int(defval=9999,title="ToYear",minval=2017, group = 'Time filters')
start=timestamp(FromYear,FromMonth,FromDay,00,00)
finish=timestamp(ToYear,ToMonth,ToDay,23,59)
window()=>time>=start and time<=finish?true:false
afterStartDate = time >= start and time<=finish?true:false
closeTradesEOD = input.bool(false, 'Close trades end of day', group = 'Time filters')

trailStopMA = ta.ema(close, trailStopMALength)

isGreenCandle = close > open
isRedCandle = close < open
isBrokenHigh = close > open[1]
isPriorCandleRed = close[1] < open[1]
isPriorPriorCandleRed = close[2] < open[2]
isPriorPriorCandleGreen = close[2] > open[2]
isPriorCandleGreen = close[1] > open[1]
isBrokenLow = close < open[1]

isPriorRedCandleBroken = isGreenCandle and isPriorCandleRed and isBrokenHigh
isPriorGreenCandleBroken = isRedCandle and isPriorCandleGreen and isBrokenLow

isPriorPriorRedCandleBroken = secondEntryEnabled and not isPriorRedCandleBroken and isGreenCandle and isPriorPriorCandleRed ? close > open[2] : false
isPriorPriorGreenCandleBroken = secondEntryEnabled and not isPriorGreenCandleBroken and isRedCandle and isPriorPriorCandleGreen ? close < open[2] : false

longOpenCondition = (isPriorRedCandleBroken or isPriorPriorRedCandleBroken) and afterStartDate and (ignoreSlowMA ? close > fastMA : fastMA > slowMA) and longsEnabled
longCloseCondition = useOpposingBarAsExit ? isRedCandle : ta.crossunder(close, fastMA)
longCloseCondition := useEMAForStop ? ta.crossunder(close, trailStopMA) : longCloseCondition

shortOpenCondition = (isPriorGreenCandleBroken or isPriorPriorGreenCandleBroken) and afterStartDate and (ignoreSlowMA ? close < fastMA : fastMA < slowMA) and shortsEnabled
shortCloseCondition = useOpposingBarAsExit ? isGreenCandle : ta.crossover(close, fastMA)
shortCloseCondition := useEMAForStop ? ta.crossover(close, trailStopMA) : shortCloseCondition

if (longOpenCondition)
    strategy.entry("Long Entry", strategy.long)

if (longCloseCondition)
    strategy.close('Long Entry', 'Long Exit')

if (shortOpenCondition)
    strategy.entry("Short Entry", strategy.long)

if (shortCloseCondition)
    strategy.close('Short Entry', 'Short Exit')

if (closeTradesEOD and hour >= 14 and minute >= 30)
    strategy.close_all("EOD")

plot(useEMAForStop ? trailStopMA : na, linewidth = 2, color = color.red)
plot(fastMA)
plot(ignoreSlowMA ? na : slowMA, linewidth = 4)