
これは,metrobonez1ty戦略テスト器に基づいて開発された強化型定量化取引戦略である.この戦略の主な特徴は,多層の利益目標と動的止損機構を実現し,外部指標信号との統合の柔軟性を維持することである.この戦略は,最大3つの利益目標位置をサポートし,指数に基づく止損トリガーを選択的に使用し,追加信号の確認によって取引の入場時間をフィルターする.
戦略の核心論理は,多層の退出機構を中心に展開している.入場方面では,戦略は,longEntryとshortEntryの2つの入力源を通じて多頭と空頭取引シグナルを誘発している.各取引方向に対して,戦略は,3つの独立した利益目標 (TP1,TP2,TP3) を設定しており,各目標は,外部指標信号に基づいて動的に調整することができる.同時に,戦略は,市場条件に応じて柔軟にストップロスの位置を調整できるダイナミックなストップロスの仕組みを導入している.戦略はまた,取引を誘発するために複数の指標を共同承認するコンフルーエンスベースのフィルタリング機構を実現している.
この戦略は,多層の利益目標とダイナミックな止損機構によって,包括的な取引枠組みを提供する.戦略の優点は,その柔軟性とカスタマイズ性にあるが,同時に,パラメータ最適化と市場適応性の問題を慎重に扱う必要もある.戦略は,推奨された最適化方向によって,その安定性と適応性をさらに高め,より完全な取引システムになる.
/*backtest
start: 2025-02-04 00:00:00
end: 2025-02-18 08:00:00
period: 4h
basePeriod: 4h
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("Enhanced Strategy Tester with multi TP and SL Trigger", overlay=true, margin_long=100, margin_short=100)
// Entry Signals
longEntry = input.source(close, 'Long Entry Trigger', 'long signal source')
shortEntry = input.source(close, 'Short Entry Trigger', 'short signal source')
// Exit Triggers
activateLongExit = input.bool(false, 'Activate Long Exit Signals')
longExit1 = input.source(high, 'Long Exit TP1')
longExit2 = input.source(high, 'Long Exit TP2')
longExit3 = input.source(high, 'Long Exit TP3')
activateShortExit = input.bool(false, 'Activate Short Exit Signals')
shortExit1 = input.source(low, 'Short Exit TP1')
shortExit2 = input.source(low, 'Short Exit TP2')
shortExit3 = input.source(low, 'Short Exit TP3')
// Stop Loss from External Indicator
useSLSignal = input.bool(false, 'Activate SL Signal')
slSignal = input.source(low, 'SL', 'SL Signal Source')
// Long Entry Condition
longCondition = not na(longEntry) and longEntry > 0
if (longCondition and strategy.opentrades == 0)
strategy.entry('long', strategy.long)
strategy.exit('exit_long_tp1', 'long', limit=longExit1, comment='TP1 hit')
strategy.exit('exit_long_tp2', 'long', limit=longExit2, comment='TP2 hit')
strategy.exit('exit_long_tp3', 'long', limit=longExit3, comment='TP3 hit')
strategy.exit('exit_long_sl', 'long', stop=useSLSignal ? slSignal : na, comment='SL hit')
// Long Exit Condition
if (activateLongExit)
if (not na(longExit1) and longExit1 > 0)
strategy.close('long', comment='TP1 at Exit')
if (not na(longExit2) and longExit2 > 0)
strategy.close('long', comment='TP2 at Exit')
if (not na(longExit3) and longExit3 > 0)
strategy.close('long', comment='TP3 at Exit')
// Short Entry Condition
shortCondition = not na(shortEntry) and shortEntry > 0
if (shortCondition and strategy.opentrades == 0)
strategy.entry('short', strategy.short)
strategy.exit('exit_short_tp1', 'short', limit=shortExit1, comment='TP1 hit')
strategy.exit('exit_short_tp2', 'short', limit=shortExit2, comment='TP2 hit')
strategy.exit('exit_short_tp3', 'short', limit=shortExit3, comment='TP3 hit')
strategy.exit('exit_short_sl', 'short', stop=useSLSignal ? slSignal : na, comment='SL hit')
// Short Exit Condition
if (activateShortExit)
if (not na(shortExit1) and shortExit1 > 0)
strategy.close('short', comment='TP1 at Exit')
if (not na(shortExit2) and shortExit2 > 0)
strategy.close('short', comment='TP2 at Exit')
if (not na(shortExit3) and shortExit3 > 0)
strategy.close('short', comment='TP3 at Exit')