Contrarian_RSI_Oversold_Spike¶
EA0137_Contrarian_RSI_Oversold_Spike_v1.0 / ⚠️ FAILED — 生成失敗・修正失敗・BT不合格
ワンライナー
Contrarian RSI Oversold Spike
判定: 🟡 C(ひとクセあり)
自律生成EA。優位性は限定的(PF0.73)。データとしては残すが運用向きではない。
自律生成ライン(網羅的に量産)
基本情報¶
| 項目 | 値 | 項目 | 値 | |
|---|---|---|---|---|
| シンボル | USDJPY | エントリー種別 | oscillator_reversal | |
| 時間足 | H1 | エグジット | fixed_sl | |
| 方向 | both | 主要インジケータ | — |
🧬 DNA 5軸¶
| primary_style | entry_mechanism | regime_target | position_logic | core_indicator_family |
|---|---|---|---|---|
mean_reversion | oscillator_reversal | volatile | fixed_sl | oscillator |
📊 バックテスト結果¶
判定: ❌ FAIL / 期間: — 〜 —
| PF | 損益率 | 勝率 | 最大DD | シャープ | 取引数 |
|---|---|---|---|---|---|
| 0.73 | -2.18% | 87.5% | 5.00% | -4.92 | 24 |
📝 仕様書 / Specification¶
クリックで展開
リサーチEA仕様書: Contrarian RSI Oversold Spike¶
EA識別情報¶
- EA名: REF0609_06_Contrarian_RSI_Oversold_Spike_v1
- 通貨ペア: USDJPY
- 時間足: H1
- プライマリスタイル: mean_reversion
- エントリーメカニズム: oscillator_reversal
- レジームターゲット: volatile
- ポジションロジック: fixed_sl
- コアインジケーター系統: oscillator
- キャプチャ意図: middle (head=新規の頭を取る / middle=頭と尻尾を渡す / tail=枯れ際の反転を取る)
リサーチテーゼ¶
Contrarian RSI Oversold Spike 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.
根拠ソース¶
- [CONTRA] 「勝率90%」を謳う戦略はほぼ確実に マーチンゲール / ナンピン / 無SL のいずれか、中長期で破綻
- [CONTRA] バックテストで「きれいな右肩上がり」はカーブフィッティングの兆候、実運用で逆転
- [CONTRA] 「無敗のEA」「必勝EA」の商業売りは詐欺、本物は売らない
- [CONTRA] 新しい指標の組み合わせより、既存戦略に「時間帯フィルター」追加の方が有効なことが多い
トレード仕様¶
以下5点は必須です。いずれかが欠落・空欄の場合、この仕様書は不合格としてください。
1. Entry logic(エントリー条件)¶
Keltner-CCI Mean Reversion entry (low-volatility regime only): Step 1 — Keltner squeeze check on bar[2] (historical, NOT bar[1]): kcUpper = ema20[2] + 1.5*atr14[2], kcLower = ema20[2] - 1.5*atr14[2]. Active only when BB(20,2) width < KC width on bar[2]: lowVolRegime = (bbUpper[2] - bbLower[2]) < (kcUpper - kcLower). Step 2 — CCI(14) reversal signal on bar[1]: BUY: cci[1] > InpCCIOversold && cci[2] <= InpCCIOversold (default InpCCIOversold=-100). SELL: cci[1] < InpCCIOverbought && cci[2] >= InpCCIOverbought (default InpCCIOverbought=100). Step 3 — Direction confirmation on bar[1]: BUY requires close[1] > open[1]; SELL requires close[1] < open[1]. Full BUY condition: lowVolRegime && cci[1] > InpCCIOversold && cci[2] <= InpCCIOversold && close[1] > open[1]. Full SELL condition: lowVolRegime && cci[1] < InpCCIOverbought && cci[2] >= InpCCIOverbought && close[1] < open[1]. CRITICAL: squeeze (step 1) MUST be checked on bar[2], CCI signal (step 2) on bar[1]. Checking both on the same bar causes NO_TRADE — squeeze = low vol, CCI extreme = momentum spike, they rarely coexist on the same bar. Regime filter (independent): use ONLY lowVolRegime; do not add price-vs-EMA as a second regime gate. The directional candle is confirmation, not regime. ONE regime variable only: use ONLY lowVolRegime in the entry condition — do NOT add directional price-vs-EMA regime gates. NOTE: oscillator_reversal + ranging regime has been REMOVED from the DNA pool due to statistical contradiction (RSI extremes require strong price moves that typically push price outside ranging bounds). This low_vol variant is retained because Keltner squeeze + CCI operates on volatility compression, not ranging regime.
2. Exit logic(決済条件)¶
Take profit: (1) CCI returns to zero line — for longs: CCI[1] > 0; for shorts: CCI[1] < 0, OR (2) price reaches EMA20 — whichever fires first. 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=12) if neither TP nor SL triggered (stale low-vol reversion = structural failure, not an opportunity). Regime exit: if lowVolRegime is false for two consecutive confirmed bars, close immediately.
2.5 キャプチャ意図に基づく Exit Discipline (拘束)¶
キャプチャ意図: MIDDLE — Middle capture: give up the head and the tail. The EA must not chase the extension; it locks in a measured portion and steps aside.
- TP: ATR(14, bar[1]) × 1.5
- SL: ATR(14, bar[1]) × 1.5
- トレイル: トレイル禁止
- 時間切れ: 15 bars
- 部分決済: +1.0*ATR で 50% 部分決済 + 残りは建値SLへ
EA 実装ガードレール (絶対遵守):
- NEVER add a trailing stop — middle capture forbids tail-chasing.
- TP and SL are equal in ATR multiples (1.5 each); do NOT widen TP > SL.
- Time exit at 15 bars is mandatory; do NOT extend in pursuit of further gains.
- Partial close at +1.0*ATR with BE stop is the only allowed exit refinement.
参考 MQL5 擬似コード (実装の出発点):
double atrAtEntry = iATR(_Symbol, _Period, 14)[1];
double tp = entryPrice + side * 1.5 * atrAtEntry;
double sl = entryPrice - side * 1.5 * atrAtEntry;
// NO trailing stop — middle capture explicitly refuses to chase the tail.
// Partial close: close 50% of position at +1.0 * atrAtEntry favorable excursion.
if (favorableExcursion >= 1.0 * atrAtEntry && !partialClosed) {
ClosePartial(0.5); partialClosed = true;
// Move remaining stop to break-even.
ModifyStop(entryPrice);
}
// Time exit: 15 bars from entry, regardless of P/L.
if (barsHeld >= 15) { ClosePosition("middle_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(レジームフィルター)¶
volatile 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
- Contrarian safety filter: after 3 consecutive losing trades, disable new entries for the next 10 bars
ロジック独立性要件¶
必須チェック(実装前に確認すること):
- エントリーシグナル変数とレジームフィルター変数は独立したデータ源または独立した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: 4 prior infra/incomplete run(s) for this DNA
- ledger: recent incomplete/infrastructure penalty applied (⅘ runs)
- 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)
- [META] HistorySelect(0, TimeCurrent()) は全取引履歴を走査対象にするため、長期運用や多数の取引がある口座ではパフォーマンスに影響する。連敗カウント等の直近履歴のみが必要な場合は、開始時刻を限定する(例: TimeCurrent() - 30243600)か、最後のチェック時刻を記録して差分走査にする。 (.clinerules)
- [META] MQL5のOnTradeTransactionではDEAL_ENTRY_INOUTも処理対象に含めないと、ネッティング口座での約定イベントを捕捉できない場合がある (.clinerules)
- [META] OnTradeTransactionでHistoryDealSelectを使用する際、DEAL_ENTRY_OUTとDEAL_ENTRY_INOUTの両方を処理することで、ネッティング口座とヘッジ口座の両方に対応できる。この2値チェックパターンは連敗カウント等の決済イベント処理の標準実装として有効。 (.clinerules)
- [META] OnTradeイベントでHistorySelect(0, TimeCurrent())による全履歴スキャンは、取引履歴が長期化するとパフォーマンス劣化を招く。g_last_processed_dealに対応する時刻を別途保持し、HistorySelectの開始時刻を直近に絞り込むパターンが推奨される。 (.clinerules)
- [META] OnTrade内のHistorySelectの時間範囲設計: HistorySelect(TimeCurrent() - N, TimeCurrent())のNが短すぎると、処理遅延や複数決済重複時に取りこぼしが発生する。最低でも300秒(5分)以上を推奨。 (.clinerules)
- [META] [E2] bid/askの取得にSymbolInfoDouble(_Symbol, SYMBOL_BID/ASK)を使用しているが、その前にRefreshRates()を呼んでいない。CSymbolInfoクラスを使用していないため、最新レートの保証がない。 (.clinerules)
ストーリーパッケージ¶
- フック: AIが研究メモから自律発掘した「Contrarian RSI Oversold Spike」をEA化して検証。
- ブログアングル: 研究アイデアは本当にMT5で再現できるのか、OOSで崩れるかまで公開する。
- 失敗アングル: 失敗時は NO_TRADE / LOW_SAMPLE / OVERFIT / HIGH_DD に分類して次の研究候補へ進む。
Spec Validation Warnings (auto-generated)¶
- CONTRADICTION: レジームターゲットとエントリーロジックの根本的矛盾: Regime filterセクションで「volatile regime confirmation」と要求されているが、Entry logicでは「low-volatility regime only」と定義されている。volatile(高ボラ)とlow-volatility(低ボラ)は互いに排他的なため、両条件を同時に満たすバーは存在しない。
- Fix: レジームターゲットをlow-volatilityに統一するか、Regime filterセクションの記述をlow-volatility regime confirmationに修正すること。両方のセクションで一貫したレジーム定義を使用すること。
- WARNING: Entry logic内の名称・インジケーター不一致: EA名・コアコンセプトが「Contrarian RSI Oversold Spike」とRSIベースであるが、実際のエントリーロジックはCCI(14)を使用している。仕様書タイトルと実装の不一致。
- Fix: EA名を「Contrarian CCI Oversold Spike」に変更するか、エントリーロジックをRSI(14)に変更して名称と一致させること。
- WARNING: Exit logicとExit DisciplineのTP/SL定義矛盾: Section 2ではTPが「CCI returns to zero line OR price reaches EMA20」という条件付きTPだが、Exit Disciplineでは「TP: ATR(14, bar[1]) × 1.5」という固定距離TPを要求。両者は互換しない。
- Fix: 仕様書内で「Exit Discipline を優先」と明記されているため、Section 2のTP定義をATRベース固定距離TPに統一すること。
- WARNING: Exit logicとExit DisciplineのSL定義矛盾: Section 2では「ATR(14)1.5 beyond entry bar」とあるが、Exit Disciplineでは「SL: ATR(14, bar[1]) × 1.5」とある。Section 2の「beyond entry bar」はエントリーバーの高値/安値を基準にする可能性があり、Exit Disciplineの「entryPrice ± 1.5ATR」と厳密には異なる。
- Fix: Exit Disciplineを優先し、SLをentryPrice ± 1.5*ATRとして明確に定義すること。
- WARNING: Time exitの数値矛盾: Section 2では「InpMaxBars (default=12)」と定義されているが、Exit Disciplineでは「15 bars」と定義されている。同一仕様書内で異なるデフォルト値。
- Fix: Exit Disciplineを優先し、time exitを15 barsに統一すること。
- WARNING: Regime exitとExit Disciplineの優先順位未解決: Section 2に「Regime exit: if lowVolRegime is false for two consecutive confirmed bars, close immediately」とあるが、Exit Disciplineにはこのregime exitが含まれていない。Exit Disciplineが優先される場合、このregime exitは無視される可能性がある。
- Fix: Exit Disciplineにregime exitを明示的に追加するか、Section 2のregime exitを廃止してExit Disciplineに統一すること。
- WARNING: Source Evidenceセクションの[CONTRA]項目(時間帯フィルターの有効性等)がFiltersセクションに具体的な実装として反映されていない。'Spread and session filter'としか記載されており、Source Evidenceで示された知見が実装に落とし込まれていない可能性。
- WARNING: Entry logicのNOTEに「oscillator_reversal + ranging regime has been REMOVED from the DNA pool due to statistical contradiction」とあるが、本EAのプライマリスタイルは「mean_reversion」であり、oscillator_reversalと低ボラレジームの組み合わせは統計的矛盾が指摘されているにも関わらず採用されている。低ボラでのオシレーター極値は理論的に起きにくい(極値には価格変動が必要)ため、取引頻度が極端に低い可能性。
- WARNING: CCIのoversold閾値が-100だが、CCIは±100を標準的な閾値とする。RSIの30/70とは異なり、CCIの-100は強い極値ではない。統計的にはCCIが-100を下回る頻度が高すぎるか、またはKeltner squeeze条件との組み合わせで取引が稀になる可能性。
- WARNING: 「キャプチャ意図: MIDDLE」でありながら、Entry logicのStep 3で「BUY requires close[1] > open[1]」(陽線)を要求している。オシレーター逆張りでmean_reversionを狙う場合、極値後の最初の陽線は反転の「頭」を取る動きであり、MIDDLEキャプチャの思想とやや矛盾する可能性。
- WARNING: Filtersセクションの「Contrarian safety filter: after 3 consecutive losing trades, disable new entries for the next 10 bars」が、エントリー条件のANDに含まれるか、別モジュールとして動作するか不明瞭。3連敗の定義(確定ベースか未確定含むか)も未定義。
- WARNING: 「レジーム変数は1本のみ」の要件はEntry logic内で遵守されているが、Regime filterセクションの「volatile regime confirmation」との整合性が取れていない。volatile確認用の独立したレジーム変数が暗黙に存在する可能性。
免責事項
本EAは自動生成された検証用コードです。実運用可否はご自身で検証してください。
関連用語¶
- 用語集 - RSI
- 用語集 - バックテスト
- 用語集 - 勝率
- 用語集 - カーブフィッティング
- 用語集 - ATR
- 用語集 - TimeCurrent
- 用語集 - SymbolInfoDouble
- 用語集 - EMA
- 用語集 - 逆張り