
これは,トレンド追跡に基づく突破策である。突破が発生したときに強引なインプットを持つ株を購入し,突破が発生したときに弱気のある株を売却し,トレンド追跡を実現する。
この策略は,主に2つの指標に基づいて,入場と退出信号を判断する. 一つは, highest () 関数の判断による一定の周期内の最高値であり,もう一つは, lowest () 関数の判断による一定の周期内の最低値である.
閉盘価格が過去一定周期 (パラメータhighPeriod) の最高価格より高いときは,上昇傾向の突破であると考え,多信号を発する.閉盘価格が過去一定周期 (パラメータlowPeriod) の最低価格より低いときは,下降傾向の突破であると考え,空信号を発する.
この戦略は,移動ストップと固定ストップを同時に設定する.移動ストップはATR指数に基づいて,一定の周期内のATR値を計算し,その倍数 ((パラメータtrailingAtrMultiplier) を移動ストップ位として乗算する.固定ストップも同様にATR指数に基づいて計算される.
固定ストップは,多空した最初のルートKラインで効く.その後,移動ストップをメインに変換する.この組み合わせは,トレンドを追跡しながら,利益の一部をロックすることができます.
この戦略はまた,ポジション計算の規則を設定している. 最大許容可能な損失のパーセント,口座権益などのベースでポジションを計算している. 取引品種の数を考慮し,単一の品種のポジションを適切に減少している.
概して,これは典型的なトレンドフォロー型の戦略で,突破が発生すると判断したときにフィールドに入り,ストップスロップで利益をロックしてトレンドを追跡し,トレンドが逆転すると外出する.
この戦略は突破的なもので,その主な利点は以下の通りです.
トレンド判断の正確さ。最高価格と最低価格でトレンドが逆転したかどうかを判断する,正確性が高く,誤った信号を出すことは容易ではない。
ポジションと止損科学は合理的である.最大損失比率の設定,口座権益関連等がポジションを合理的にし,過剰量または無効取引を避ける.組合せ止損方法は,利益をロックし,トレンドの運行を追跡する.
シンプルで実用的で,使いやすい. 必要なのは,最も基本的な指標のみで,戦略の論理はシンプルで明確で,容易に掌握できる.
拡張性が良い。指標パラメータ,ポジションルールなども入力ボックスが提供されており,ユーザは必要に応じて調整することができる。
全体として,これは実用的で強力な突破策である。判断上は安全で信頼性があり,同時に,リスク管理と追跡を考慮して戦略設計されている。中長線保有に適している。
この戦略の主なリスクは,
トレンド反転のリスク. 突破策はトレンド判断に大きく依存し,誤った判断で巨額の損失に直面する可能性があります.
参数不適切なリスク.最高価格最低価格周期参数選択不適切はトレンドを逃す可能性があり,ポジションパラメータの設定不適切は過大な損失を引き起こす可能性がある.
ストップダメージが激進的すぎるリスク.移動ストップダメージの距離が小さすぎる場合,市場騒音によって外出される可能性があります.
解決策は以下の通りです.
トレンドフィルターを追加する.例えば,他の指標の判断を加え,誤った突破を避ける.
最適化パラメータ選択。パラメータをテストして最適化値を取って,その安定性を確保する。
止損距離は適正に緩められる。止損距離が一定回調を容認できるようにする。
この戦略は以下の方向から最適化できます.
傾向判断の指標を追加する.最高最低価格に加えて,移動平均などの判断を加えることができ,傾向判断をより正確にする.
最適化パラメータ設定.最高最低価格周期パラメータ,止損倍数パラメータなどにテストを行い,最適のパラメータ組み合わせを選択する.
市場調整のポジションアルゴリズムに従って。ポジションを市場の変動に結びつけることができる.例えばVIXが上昇するとポジションを下げる。
増量能指針フィルター.増量能の突破時にのみ入って,偽突破を避ける.
基差と関連性 優遇取引品種を考慮する.基差の変動が小さい,関連性が低い品種組合せを選択することで,組合せリスクを低減する.
ストップメカニズムの最適化と調整 移動ストップと固定ストップの比率の組み合わせをテストし,ストップが過度に激進するリスクを低減する
この戦略は,トレンド追跡型の突破策として,判断の正確性,ポジションとリスクの制御,操作の簡素性などにおいて,よく機能している.これは,トレンドの初期段階をキャプチャし,移動のストップ損失によって利益のロックとトレンド追跡をバランスしている.
もちろん,突破策として,トレンド判断への依存度が非常に高く,ノイズによる干渉に容易である.また,パラメータの設定が不適切であることも,戦略のパフォーマンスに影響を与える可能性がある.これは,さらなる最適化によって解決する必要がある.
全体として,これは非常に実用的な戦略であり,その基本的な構造は,すでに定量化戦略に必要な最も重要な要素を含んでいます. 継続的に最適化および改善することができれば,安定した収益性のプログラム化戦略に完全にすることができます.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(shorttitle="Trend Surfers - Breakout", title="Trend Surfers - Premium Breakout",
overlay=true)
// Risk for position and pyramid
maxriskval = input(2, "Max % risk", type = input.float,
tooltip="Risk % over total equity / Position", group = "Risk Management")
pairnumber = input(title = "How many pairs",type = input.integer, defval= 1,
tooltip="How many pairs are you trading with the strategy?", group = "Risk Management")
// Emtry Exit
highPeriod = input(title="Highest High Period", type=input.integer, defval=168
, tooltip="Highest High of X bars - This will trigger a Long Entry when close is above. (Thin Green Line)"
, group = "Entry Condition")
lowPeriod = input(title="Lowest Low Period", type=input.integer, defval=168,
tooltip="Lowest low of X bars - This will trigger a Short Entry when close is under. (Thin Red Line)"
, group = "Entry Condition")
// Stoploss
trailingAtrPeriod = input(title="Trailing ATR Pediod", type=input.integer, defval=10,
tooltip="Average True Range for the Trailing Stop. (Thick Green Line) "
, group = "Exit Condition")
trailingAtrMultiplier = input(title="Trailing ATR Multiplier", type=input.float, defval=8
, group = "Exit Condition")
fixAtrPeriod = input(title="Fix ATR Pediod", type=input.integer, defval=10,
tooltip="Average True Range for the Fix Stoloss. (Thick Yellow Line)"
, group = "Exit Condition")
fixAtrMultiplier = input(title="Fix ATR Multiplier", type=input.float, defval=2
, group = "Exit Condition")
// Pair info
pair = syminfo.basecurrency + syminfo.currency
// High Low Variable
highestHigh = highest(high, highPeriod)[1]
lowestLow = lowest(low, lowPeriod)[1]
trailingAtr = atr(trailingAtrPeriod) * trailingAtrMultiplier
// Trade Condition
longCondition = crossover(close, highestHigh)
shortCondition = crossunder(close, lowestLow)
// Risk Variable
fixAtr = atr(fixAtrPeriod) * fixAtrMultiplier
stopvaluelong = close[1] - fixAtr[1]
stopvalueshort = close[1] + fixAtr[1]
// Position size Long
maxpossize = strategy.equity / close
positionsizelong = ( ( ( (maxriskval/100) * strategy.equity) / (close - stopvaluelong)))
stopperclong = ((close - stopvaluelong) / close) * 100
leveragelong = max(1, ceil(positionsizelong / maxpossize)) * 2
posperclong = (((positionsizelong * close) / strategy.equity) *100 / leveragelong) / pairnumber
realposlong = (((posperclong / 100) * strategy.equity) * leveragelong) / close
// Position size Short
positionsizeshort = ( ( ( (maxriskval/100) * strategy.equity) / (stopvalueshort - close)))
stoppercshort = ((close - stopvalueshort) / close) * 100
leverageshort = max(1, ceil(positionsizeshort / maxpossize)) * 2
pospercshort = (((positionsizeshort * close) / strategy.equity) *100 / leverageshort) / pairnumber
realposshort = (((pospercshort / 100) * strategy.equity) * leverageshort) / close
// Alert Message
entry_long_message = '\nGo Long for ' + pair + 'NOW!' +
'\nPosition Size % =' + tostring(posperclong) +
'\nLeverage' + tostring(leveragelong) +
'\nStoploss Price =' + tostring(stopvaluelong) +
'\nClose any Short position that are open for ' + pair + '!' +
'\n\nVisit TrendSurfersSignals.com' +
'\nFor automated premium signals (FREE)'
entry_short_message ='\nGo Short for ' + pair + 'NOW!' +
'\nPosition Size % =' + tostring(pospercshort) +
'\nLeverage' + tostring(leverageshort) +
'\nStoploss Price =' + tostring(stopvalueshort) +
'\nClose any Long position that are open for ' + pair + '!' +
'\n\nVisit TrendSurfersSignals.com' +
'\nFor automated premium signals (FREE)'
exit_short_message = '\nExit Short for ' + pair + 'NOW!' +
'\n\nVisit TrendSurfersSignals.com' +
'\nFor automated premium signals (FREE)'
exit_long_message = '\nExit Long for ' + pair + 'NOW!' +
'\n\nVisit TrendSurfersSignals.com' +
'\nFor automated premium signals (FREE)'
// Order
if longCondition
strategy.entry("Long", strategy.long, stop=highestHigh, comment="Long", qty=realposlong
, alert_message = entry_long_message)
if shortCondition
strategy.entry("Short", strategy.short, stop=lowestLow, comment="Short", qty=realposshort
, alert_message = entry_short_message)
// Stoploss Trailing
longTrailing = close - trailingAtr
shortTrailing = close + trailingAtr
var longTrailingStop = 0.0
var shortTrailingStop = 999999.9
trailingStopLine = 0.0
trailingStopLine := na
fixedStopLine = 0.0
fixedStopLine := na
var inTrade = 0
if longCondition or shortCondition
if 0 == inTrade
if longCondition
inTrade := 1
else
inTrade := -1
if 1 == inTrade and (shortCondition or low <= max(fixedStopLine[1], longTrailingStop))
inTrade := 0
if -1 == inTrade and (longCondition or high >= min(fixedStopLine[1], shortTrailingStop))
inTrade := 0
longTrailingStop := if (1 == inTrade)
stopValue = longTrailing
max(stopValue, longTrailingStop[1])
else
0
shortTrailingStop := if (-1 == inTrade)
stopValue = shortTrailing
min(stopValue, shortTrailingStop[1])
else
999999
// Fix Stoploss
firstPrice = 0.0
firstFixAtr = 0.0
firstPrice := na
firstFixAtr := na
if 0 != inTrade
firstPrice := valuewhen(inTrade != inTrade[1] and 0 != inTrade, close, 0)
firstFixAtr := valuewhen(inTrade != inTrade[1] and 0 != inTrade, fixAtr, 0)
if 1 == inTrade
fixedStopLine := firstPrice - firstFixAtr
trailingStopLine := longTrailingStop
else
fixedStopLine := firstPrice + firstFixAtr
trailingStopLine := shortTrailingStop
if (strategy.position_size > 0)
strategy.exit(id="L Stop", stop=max(fixedStopLine, longTrailingStop)
, alert_message = exit_long_message)
if (strategy.position_size < 0)
strategy.exit(id="S Stop", stop=min(fixedStopLine, shortTrailingStop)
, alert_message = exit_long_message)
// Plot
plot(highestHigh, color=color.green, linewidth=1, transp=0, title='Highest High')
plot(lowestLow, color=color.red, linewidth=1, transp=0, title='Lowest Low')
plot(trailingStopLine, color=color.lime, linewidth=2, transp=0, offset=1, title='Trailing Stop')
plot(fixedStopLine, color=color.orange, linewidth=2, transp=0, offset=1, title='Fixed Stop')