Session-Filtered_Divergence_Fade¶
EA0146_Session-Filtered_Divergence_Fade_v1.0 / 🧪 候補 — 生成済み・検証待ち
ワンライナー
Session-Filtered Divergence Fade
判定: ⚫ 散(散る(検証に乗らず))
自律生成EA。エントリー不成立 or 検証未成立で評価対象外。量産の中で淘汰された一体。
自律生成ライン(網羅的に量産)
基本情報¶
| 項目 | 値 | 項目 | 値 | |
|---|---|---|---|---|
| シンボル | GBPUSD | エントリー種別 | rsi_divergence | |
| 時間足 | H1 | エグジット | fixed_sl | |
| 方向 | both | 主要インジケータ | — |
🧬 DNA 5軸¶
| primary_style | entry_mechanism | regime_target | position_logic | core_indicator_family |
|---|---|---|---|---|
mean_reversion | rsi_divergence | ranging | fixed_sl | oscillator |
📊 バックテスト結果¶
未実行
📝 仕様書 / Specification¶
クリックで展開
リサーチEA仕様書: Session-Filtered Divergence Fade¶
EA識別情報¶
- EA名: REF0613_04_Session_Filtered_Divergence_Fade_v1
- 通貨ペア: EURUSD
- 時間足: H1
- プライマリスタイル: mean_reversion
- エントリーメカニズム: rsi_divergence
- レジームターゲット: ranging
- ポジションロジック: fixed_sl
- コアインジケーター系統: oscillator
- キャプチャ意図: tail (head=新規の頭を取る / middle=頭と尻尾を渡す / tail=枯れ際の反転を取る)
リサーチテーゼ¶
Session-Filtered Divergence Fade candidate generated from 1 research source(s). The strategy must preserve the source idea while keeping parameters broad enough to survive out-of-sample testing.
根拠ソース¶
- [FILTER] 曜日フィルター: 月曜早朝と金曜夜は流動性薄でスリッページ大、原則避ける
- [FILTER] 高インパクト経済指標 (NFP/CPI/中銀声明) 前後30分のエントリー停止は DD 削減に直結
- [FILTER] [RISK] スプレッド閾値フィルター (平均スプレッドの1.5倍超でエントリー禁止) は実必須
- [FILTER] RSI ダイバージェンス確認は逆張りの精度を上げるが、順張りではダマシが増える
トレード仕様¶
以下5点は必須です。いずれかが欠落・空欄の場合、この仕様書は不合格としてください。
1. Entry logic(エントリー条件)¶
RSI Divergence entry (trend-exhaustion mean reversion, statistically coherent): BUY entry (bullish divergence in downtrend): Step 1 — Downtrend confirmed: bearishTrend = (sma50[1] < sma50[10]) (SMA50 slope negative). Step 2 — Bullish divergence: RSI makes higher low while price makes lower low over InpDivLookback bars (default=5): rsi[1] > rsi[InpDivLookback+1] && low[1] < low[InpDivLookback+1]. This means: current RSI is higher than N bars ago (momentum strengthening), BUT current price low is lower than N bars ago (price weakening) = classic bullish divergence signaling trend exhaustion. Step 3 — Confirmation candle: close[1] > open[1] (bullish bar). Full BUY condition: bearishTrend && rsi[1] > rsi[InpDivLookback+1] && low[1] < low[InpDivLookback+1] && close[1] > open[1]. SELL entry (bearish divergence in uptrend): Step 1 — Uptrend confirmed: bullishTrend = (sma50[1] > sma50[10]) (SMA50 slope positive). Step 2 — Bearish divergence: RSI makes lower high while price makes higher high: rsi[1] < rsi[InpDivLookback+1] && high[1] > high[InpDivLookback+1]. Current RSI is lower than N bars ago (momentum weakening), BUT current price high is higher than N bars ago (price strengthening) = classic bearish divergence. Step 3 — Confirmation candle: close[1] < open[1] (bearish bar). Full SELL condition: bullishTrend && rsi[1] < rsi[InpDivLookback+1] && high[1] > high[InpDivLookback+1] && close[1] < open[1]. CRITICAL — Regime confirms trend direction, completely independent from RSI: SMA50 slope measures trend direction; RSI divergence measures momentum exhaustion. These are fundamentally different concepts — NO statistical contradiction. ONE regime variable only: use ONLY bullishTrend or bearishTrend in the entry condition — do NOT add a second slope check. SAME timeframe rule: NEVER use D1 SMA or higher-timeframe indicators for regime when entry is on H1/H4. Statistical rationale: Divergence works best in established trends (ADX > 20 confirms trend exists to exhaust). Unlike oscillator_reversal + ranging which requires RSI extremes AND weak trend simultaneously (statistically contradictory), rsi_divergence explicitly needs a trend to trade against, making regime and signal naturally aligned.
2. Exit logic(決済条件)¶
Take profit: (1) RSI returns to midline — for longs: RSI[1] > 50; for shorts: RSI[1] < 50, OR (2) price reaches SMA50 (the trend mean) — whichever fires first. This captures the divergence edge: momentum normalizes and price returns to trend average. Stop loss: ATR(14)*1.5 beyond entry bar, FIXED (never trail — trailing converts reversion to trend trade). Time exit: close at bar InpMaxBars (default=16) if neither TP nor SL triggered (divergence trades need slightly more time than oscillator reversal to develop). Regime exit: if the trend direction reverses (SMA50 slope flips against position), close immediately — divergence only works when trading against an established trend; if trend reverses, the edge disappears.
2.5 キャプチャ意図に基づく Exit Discipline (拘束)¶
キャプチャ意図: TAIL — Tail capture: betting on the exhaustion / reversal at the end of a move. The winning excursion is small by construction, so TP is modest, SL is tight, and time exit is strict — if reversal does not happen quickly the thesis is wrong.
- TP: ATR(14, bar[1]) × 1.2
- SL: ATR(14, bar[1]) × 1.0
- トレイル: トレイル禁止
- 時間切れ: 10 bars
- 部分決済: 部分決済なし
EA 実装ガードレール (絶対遵守):
- NEVER add a trailing stop — tail capture explicitly does NOT ride a new opposite trend.
- TP must remain small (1.2*ATR); do NOT widen — tail excursions are bounded.
- Time exit at 10 bars is strict — a slow reversal means the exhaustion thesis is wrong.
- If the trade goes to TP and price keeps extending, that is acceptable — do NOT re-enter chasing.
参考 MQL5 擬似コード (実装の出発点):
double atrAtEntry = iATR(_Symbol, _Period, 14)[1];
double tp = entryPrice + side * 1.2 * atrAtEntry;
double sl = entryPrice - side * 1.0 * atrAtEntry;
// NO trailing — tail capture does NOT chase a new trend in the opposite direction.
// Strict time exit: 10 bars; if no reversal happened the trade is invalid.
if (barsHeld >= 10) { ClosePosition("tail_time_exit"); }
上記の Exit Discipline は section 2 (Exit logic) と矛盾する場合、Exit Discipline を優先してください。 メカニズム別の Exit 指示は同方向性の確認、Capture Intent の指示は拘束的な数値規律です。
3. Risk management(資金管理)¶
Fixed fractional risk per trade, no martingale, no grid expansion, max one position per symbol, and hard daily loss guard.
4. Regime filter(レジームフィルター)¶
ranging regime confirmation using SAME timeframe indicators only
5. Invalidation condition(無効化条件)¶
If walk-forward repeatedly shows OOS PF < 1.0 or trades collapse after loosening entry filters, archive the DNA.
5点構造チェック: 上記5セクションがすべて記載されていることを確認してください。
フィルター¶
- Spread and session filter
- Regime-specific confirmation filter from source evidence
- Minimum ATR activity filter
ロジック独立性要件¶
必須チェック(実装前に確認すること):
- エントリーシグナル変数とレジームフィルター変数は独立したデータ源または独立したlookbackから計算すること
- 悪い例:
bullishCross = fastMA[1] > slowMA[1]とisBearishRegime = fastMA[1] < slowMA[1]を AND 結合 → 同一バーで両立不可、取引ゼロになる - 正しいレジーム定義:
slowMA[1] - slowMA[10]の傾き、上位足のMA方向、長い lookback(50本以上)の傾き - 全フィルターを AND 結合した時に、理論上発火できるバーが存在することをスケッチで確認すること
- 逆張り戦略では「エントリー条件の否定 ≠ レジーム条件」になっているか必ず確認すること
- RSI・BB・ATR など同一インジケーターを「シグナル源」と「フィルター源」の両方に使う場合、同じバーで矛盾する不等式を要求していないか確認すること
- レジーム変数は1本のみ:
bullishRegime(またはuptrend等) という bool 変数を1つ定義し、エントリー条件の AND に使うのはその1変数のみにすること。bullishRegime && regimeUpのように2本のレジーム変数を AND 結合することを禁止する。スロープ・価格位置・ADX など複数軸で判断したい場合は、それらを統合した1本の bool 変数にまとめてから AND に組み込むこと。
最適化許容範囲¶
- 緩和可能: 確証閾値、ATR活性閾値、セッションウィンドウ、シグナル確証バー数。
- 緩和不可: 損切り規律、最大ポジション数1、過去の固定価格水準の不使用。
- 明示的に正当化される場合のみ特殊アプローチを許可: ブローカー非対称性の活用、出金ありマーチンゲール戦略、逆張りセンチメントフェード、地政学イベント裁定、構造的レイテンシエッジ、量子風最適化、群知能ポジションサイジング、ゲーム理論的マーケットメイキング。
- 特殊アプローチを使用する場合は以下を必須記載: (1) 1トレードおよび1日あたりの厳密なリスク上限(pips/%)、(2) キルスイッチ条件(取引停止条件)、(3) 構造的エッジの存在根拠、(4) エッジ消失時の標準ルールへのフォールバック。
- 多様性指令: レジストリ内の既存EAがほとんどTREND系ならMRかBREAKOUTを生成。ほとんどテクニカル指標ベースなら、異常/季節/レジームベースまたは学際的(物理/生物/心理)アプローチを生成。未探索の角度を追求すること。
- 初期最適化範囲: 3〜5パラメータのみ。
- 取引ゼロの場合: まずエントリー確証を緩和、次にセッション制限、次にATR閾値を緩和。
- 取引過多の場合: レジームフィルターと最小シグナル距離を強化。
バックテスト合格基準¶
- Backtest at least 24 months with the latest 3 months held out.
- Use walk-forward setting 4:2 when MT5 runner is available.
- Reject if OOS/IS PF ratio is below 0.70 or if OOS PF min is below 1.10.
- Reject if OOS trade count is below 15 trades per held-out window (minimum 30 total); first loosen entry filters before optimizing profit targets.
- OOS PF is the only success metric. IS PF is parameter sanity, not the headline.
- A profitable strategy must answer 'why does this work?' from a stated hypothesis (microstructure, behavioral bias, seasonal anomaly, regime shift). Chains of indicators with no thesis are presumed curve-fit.
過学習対策¶
- Robust > Profitable. A PF=1.20 strategy that survives every OOS window beats a PF=2.50 one that wins in one window and crashes in another.
- Keep each numeric parameter in a wide theory-backed range; do not tune to a single date range.
- Use canonical defaults (RSI=14, ATR=14, BB=20/2, MA=20/50/200). Magic numbers (RSI=17, ATR=23, BB=18/1.7) are a red flag of curve-fitting unless the spec cites prior research justifying that exact value.
- Limit optimization to 3-5 core parameters in the first pass.
- Forbid AND-chains of more than 4 filters at entry. Each added filter shrinks sample size and looks like edge but is usually fit.
- If a single time-of-day or day-of-week window dominates the trade history, the edge is calendar artifact, not strategy.
- Prefer regime filters with clear market meaning over curve-fitted thresholds.
- Stop improving the candidate after repeated NO_TRADE/LOW_SAMPLE failures.
学習フィードバック¶
- ledger: 1 prior strategy failure(s) for this DNA
- ledger: 5 prior infra/incomplete run(s) for this DNA
- ledger: recent failure streak penalty applied (⅕ strategy failures)
- ledger: recent incomplete/infrastructure penalty applied (⅗ runs)
- ledger: improve: reduce parameter count and replace brittle thresholds with regime logic
- ledger: improve: rerun the same candidate after repairing backtest artifacts
実装ガードレール¶
- [META] [RISK] [CONTRA] MT5 Strategy Testerは同名EAのinput値をキャッシュすることがあり、mq5側のinputデフォルトを変更して再コンパイルしても、BTでは前回値が使われる場合がある。inputデフォルト変更の検証では、別EA名/別ファイル名にするか、tester.ini/ExpertParametersで明示的に値を渡し、Testerログの「started with inputs」を必ず確認する。 (.clinerules)
- [RISK] [META] [CONTRA] 【部分決済後のコメント管理パターン】MQL5ではPositionModifyでコメントを変更できないため、TP1部分決済後の状態管理にコメントプレフィックスを使う設計は「二重部分決済」リスクを内包する。対策として: (1)グローバルなulong配列でTP1済みチケットを管理する、(2)部分決済後に残りを即クローズ→新コメントで再エントリーする、のいずれかのパターンを採用すること。 (.clinerules)
- [RISK] DEAL_POSITION_IDによるトレード集計: 部分決済を含むポジションでは同一ポジション由来の複数DEALが発生する。連敗カウント等のトレード単位集計にはDEAL_COMMENTではなくDEAL_POSITION_IDを使用し、カウント済みIDを配列で管理することで重複計上を防ぐ。 (.clinerules)
- [RISK] 【OnTradeTransactionによる決済検出パターン】ポジションクローズの検出にはOnTradeTransaction(trans.type == TRADE_TRANSACTION_DEAL_ADD && DEAL_ENTRY_OUT)を使用し、DEAL_POSITION_IDでエントリー管理配列と照合する設計が堅牢。HistorySelectによるポーリング方式より確実でリアルタイム性が高い。 (.clinerules)
- [TREND] [BREAKOUT] [FILTER] [META] マルチタイムフレームEAでATR等のボラティリティ指標をCopyBufferする際、エントリー判定用の価格・MA(start_pos=1で確定足参照)とATR(start_pos=0で未確定バー参照)でstart_posが混在しやすい。設計方針として「全バッファのstart_posを統一する」か「ATRのみ最新値を使う理由をコメントで明記する」かを決めておくべき。 (.clinerules)
- [FILTER] SYMBOL_SPREADはポイント単位のlong値を返すため、価格単位に変換するには
* _Pointを直接使用する (.clinerules) - [FILTER] スキャルピングEAでXAUUSD等のスプレッド変動が大きい銘柄を扱う場合、pips単位ではなく価格単位(ドル)でスプレッド閾値・トレランスを指定する設計が適切。_Digits==2環境ではpips×_Pointが意図しない極小値になる (.clinerules)
- [TREND] [FILTER] スプレッドリトライパターン(予約エントリーのスプレッド不良時リトライ): 予約フラグ方式でスプレッド不良時に即破棄せず、MAX_SPREAD_RETRY回まで次バーで再試行する設計。リトライカウンターは予約フラグと同時にリセットし、クールダウンや金曜制限等の他条件で予約破棄する際もリセットを忘れないこと。リトライの粒度(ティック単位 vs バー単位)を設計時に明確にすべき。 (.clinerules)
ストーリーパッケージ¶
- フック: AIが研究メモから自律発掘した「Session-Filtered Divergence Fade」をEA化して検証。
- ブログアングル: 研究アイデアは本当にMT5で再現できるのか、OOSで崩れるかまで公開する。
- 失敗アングル: 失敗時は NO_TRADE / LOW_SAMPLE / OVERFIT / HIGH_DD に分類して次の研究候補へ進む。
Spec Validation Warnings (auto-generated)¶
- CONTRADICTION: レジームフィルター定義の根本的矛盾: Entry logicでは「SMA50傾きでトレンド方向を確認」して「そのトレンドに逆張り」するが、Regime filterセクションでは「ranging regime confirmation(もみ合いレジーム確認)」を要求している。トレンド存在(SMA50傾き)とranging(もみ合い)は同一バーで両立しない。
- Fix: Regime filterを「trend regime confirmation」に変更するか、Entry logicを「RSI極値+弱トレンド」の純粋なオシレーターリバーサルに変更する。両方を維持するなら、レジームは「ADX > 20(トレンド存在)かつ価格がSMA50付近(過熱ではない)」のように定義し、'ranging'という記述を削除すること。
- WARNING: Entry logic内のBUY条件とSELL条件で、sma50[1]とsma50[10]の比較が同一バーで同時に真になることはないが、個別のエントリー方向では問題ない。しかし「bullishTrend = (sma50[1] > sma50[10])」と「bearishTrend = (sma50[1] < sma50[10])」が完全に排他的なため、両方向同時エントリーはない。これは意図通りだが、ranging時(sma50[1] == sma50[10])は両方falseになり取引ゼロとなる。
- Fix: ranging時(傾きゼロ)の取引ゼロは意図通りの可能性があるが、仕様書の'ranging regime'記述と合わせて確認が必要。傾きゼロを許容するなら <= / >= に変更するか、明確に除外する。
- WARNING: Exit logicとExit Disciplineの数値矛盾: Section 2ではTPが「RSI midline OR SMA50到達(どちらか早い方)」だが、Exit Disciplineでは「TP: ATR(14, bar[1]) × 1.2」に固定されている。さらにSection 2ではSLが「ATR(14)*1.5」だが、Exit Disciplineでは「SL: ATR(14, bar[1]) × 1.0」になっている。仕様書は「Exit Disciplineを優先」としているが、同じセクション内で異なる数値が記載されている。
- Fix: 仕様書の優先順位規則に従いExit Disciplineを優先するが、Section 2の記述が実装者を誤導する。Section 2を削除または「Exit Discipline参照」と明記すべき。
- WARNING: Source Evidenceに「曜日フィルター」「高インパクト経済指標前後30分停止」「スプレッド閾値フィルター」が記載されているが、Filtersセクションに具体的な実装(月曜早朝/金曜夜の時間帯定義、経済カレンダー連携、スプレッド1.5倍の数値)が落とし込まれていない。Source Evidenceを実装フィルターにマッピングすべき。
- WARNING: Entry logicのCRITICAL注釈で「ADX > 20 confirms trend exists to exhaust」と統計的根拠が述べられているが、Entry条件にADX > 20が含まれていない。注釈は実装ガイダンスではなく条件文として解釈しない方針だが、実装者が混乱する可能性がある。
- WARNING: 「Regime-specific confirmation filter from source evidence」がFiltersに記載されているが、source evidenceにはレジームに関する具体的フィルター定義が存在しない(rangingと書かれているが、実際のソースは曜日/経済指標/スプレッドのみ)。
- WARNING: RSIダイバージェンスのlookback=5はH1で5時間であり、週末や休場を跨ぐと実時間で大きくずれる可能性があるが、これは実装上の注意であり矛盾ではない。
- WARNING: Exit Disciplineの「barsHeld >= 10」はエントリーバーからのカウントだが、Entry条件がclose[1]を参照しているため、エントリーはbar[1]の確定後(bar[0]の開始時)となり、実質的なホールド時間は11本になる可能性がある。時間切れの定義を明確化すべき。
免責事項
本EAは自動生成された検証用コードです。実運用可否はご自身で検証してください。
関連用語¶
- 用語集 - バックテスト
- 用語集 - スリッページ
- 用語集 - スプレッド
- 用語集 - RSI
- 用語集 - 逆張り
- 用語集 - SMA
- 用語集 - ATR
- 用語集 - マルチタイムフレーム
- 用語集 - ボラティリティ
- 用語集 - CopyBuffer
- 用語集 - _Point
- 用語集 - スキャルピング
- 用語集 - pips
- 用語集 - _Digits
- 用語集 - ADX