Takashi Kotegawa - BNF - CIS - MA Divergence — Strategy by uzair2join

By uzair2join

Performance Metrics

Description

Description:This strategy implements a mean reversion approach inspired by the trading philosophy of BNF Kotegawa (also known as CIS), a renowned Japanese trader famous for his simple yet effective use of moving averages to identify overextensions in price. The core idea is to buy when price has fallen significantly below the 25-period SMA (indicating a potential pullback in an uptrend) and exit when it reverts back to the mean by crossing the MA. This fixed version addresses previous issues such as conflicting exit logic, race conditions in entry tracking, unprofitable short trades in uptrending assets like Gold, and non-adaptive risk management.Originality and Improvements: While based on BNF's public philosophy of mean reversion using a 25MA, this script adds modern filters and adaptive exits to make it more robust for current markets. Fixes include: removing strategy.close/exit conflicts, requiring a full MA cross for exits (not just touches), separate variables to track entries without race conditions, disabling shorts by default for uptrending instruments, replacing fixed percentage TP/SL with ATR-based levels for volatility adaptation, and making volume filters optional due to unreliable data in spot Gold feeds.How It Works:Core Signal (Divergence): Measures the percentage deviation of price from the 25-period SMA. For longs, enters when price is at least X% below the MA (default 0.15% for longs, adjustable). Shorts are optional and trigger on Y% above the MA.Filters: Incorporates RSI for oversold/overbought confirmation (e.g., RSI ≤ 40 for longs), optional reversal candle patterns (hammer, bullish engulfing), volume spikes, trend alignment via 200MA, and session filters to avoid low-liquidity periods.Exits: Supports three modes – MA Cross (BNF's method: exit on crossover back to the MA), Fixed TP/SL percentages, or ATR multiples for dynamic targets and stops. Session-end closes are enforced if enabled.Calculations: Uses SMAs for MAs, standard RSI and ATR. Entry conditions require no open position to prevent pyramiding.Visuals: Plots MAs, shades divergence zones, shows entry labels, draws active TP/SL lines, and includes an info table summarizing signal conditions (divergence, RSI, candle, volume, trend, session).How to Use:Add the script to your chart (optimized for Gold Spot on 1-5 minute timeframes, but adaptable to other trending assets).Adjust inputs via the settings panel: Set divergence thresholds based on observed pullbacks (use the info table's "vs MA25" to calibrate), choose exit mode (ATR recommended for volatility), enable/disable filters like candles or volume, set session times (default 02:00-22:00 to capture high liquidity), and toggle longs/shorts (keep shorts off for Gold).Monitor the info table for real-time condition checks and the chart for shaded zones/signals. Backtest with realistic commissions/slippage (defaults to 0.001% commission, 2 ticks slippage).Note: This is a mean reversion strategy best suited for ranging or trending markets with pullbacks; it may underperform in strong trends without reversion. Always use proper risk management – the script risks 10% of equity per trade by default.This script is open-source under the Mozilla Public License 2.0 - Test thoroughly before live use.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView