OPEN-SOURCE SCRIPT

Adaptive Bull Ratio Strategy

3 012
Overview: Why This Strategy

Most option strategies fall into two traps:
They are too rigid: A "Call Ratio Spread" works great in slow markets but gets destroyed if the market rallies hard.

They are too simple: A simple "Buy Call" suffers from time decay (Theta) if the market chops sideways.

The Adaptive Bull Ratio Strategy [ABRM] solves both. It is a living strategy that "shifts gears" based on price action.

It is called "Adaptive" because it morphs its structure three times during a trade. It starts conservative to harvest Time Decay, but if the market explodes upwards, it "uncaps" itself to ride the trend aggressively.

The Entry Philosophy: Why Supertrend?

The default setting uses the Supertrend indicator as the trigger. This is intentional:

Volatility Awareness: Supertrend adapts to market noise using ATR. In high volatility, bands widen to prevent false entries.

Trend Confirmation: Since Phase 1 involves selling options, entering "too early" against a falling market is dangerous. Supertrend forces patience, waiting for a confirmed reversal (Close > Trend Line), ensuring the momentum is actually in your favor before you commit capital.

The "Drift" Benefit: This strategy excels in markets that "drift" upwards. Supertrend identifies these trends while filtering out short-term chop.

Flexibility with External Sources:
While Supertrend is the default, the strategy is designed to be flexible. You can enable the 'Enable External Source' option in the settings to plug in any custom indicator (e.g., Moving Averages, Parabolic SAR, or a proprietary trendline).

The Golden Rule for External Sources: The script interprets a Bullish Signal whenever your External Source line is below the Close price (Ext Source < Close).

Compatibility: As long as your custom indicator behaves like a support line in an uptrend (plotting below the candles), it will work seamlessly with this strategy's logic.

The "Long Only" Rationale: Avoiding the Volatility Trap

Why not trade this on the short side (Puts) during crashes?
  1. The Volatility Trap (Vega Risk): In Bull markets, Implied Volatility (IV) usually drops, helping your sold options decay faster. In Bear markets, IV explodes (panic). Selling OTM Puts during a crash is dangerous as their value skyrockets, neutralizing gains.
  2. Velocity Risk: Bear markets crash fast ("Elevator Down"). Prices can blow through adjustment levels faster than the strategy can safely roll down, causing slippage.
  3. Structural Skew: OTM Puts are inherently more expensive. Buying expensive ITM Puts and selling expensive OTM Puts shifts the breakeven further away, making V-shape recoveries painful.


How It Works & Stands Out
This strategy actively transforms risk profiles based on market movement:

Phase 1: The "Safe" Start (Entry)

Setup: Initiates a Call Ratio Spread (Buy 2 ITM, Sell 4 OTM) + Protective Puts.
Logic: Profits from sideways drift or slow rallies via Time Decay (Theta). The sold options finance the trade.

Phase 2: The "Shift" (Adjustment Level 1)

Trigger: Market moves above Leg 2 (3 OTM Call).
Action: Rolls Up the position. Exits initial legs, enters new higher legs, and adds a Short Put to finance the roll.
Impact: Aggressive. You bet the trend is strong enough to support the added downside risk of the short put.

Phase 3: The "Uncap" (Adjustment Level 2)

Trigger: Market moves above Leg 3 (4 OTM Call).
Action: Exits all Sold Calls.
Impact: Uncaps profit potential. The trade becomes a Net Long position (Long Calls + Short Puts), allowing you to ride a massive rally without a ceiling.

Phase 4: The "Lock-In" (Optional Trail Adjustment)

Trigger: The market goes parabolic (price rises X levels above Leg 3, configurable in settings).
Action (If Enabled):
Call Adj: Exits the Phase 3 calls and buys fresh 1-OTM calls (Rolling Up to lock profits).
Put Adj: Exits all Put legs (Removing downside risk completely).
Impact: Maximum Safety. This phase is about "banking" the windfall from a massive rally and leaving a smaller, risk-free runner to capture any final extension.

How to Start: A Quick Setup Guide

Step 1: Map Expiry Dates

Manually input your trading expiry dates in Settings -> Expiry Management.
Format: YYYY-MM-DD (e.g., 2025-12-25). Strict adherence required for DhanHQ.

Step 2: Configure Symbol & Size

Exchange/Symbol: Enter NSE and NIFTY (or your ticker).
Lot Multiplier: Default is 1. Set to 2 to double all quantities (e.g., Buy 2 becomes Buy 4).

Step 3: Understand Visuals

Entry Window (Light Blue): Strategy is scanning for new trades.
Non-Entry Window (Dark Blue): Trading blocked (Day before Expiry & Expiry Day). Only management allowed.
Green Box: Valid Late Entry Zone.
Red Dashed Line: Invalidation Level (if price touches this, no late entry).
Fuchsia Line: Trigger level for Special Trail Adjustments (Phase 4).

IMPORTANT: Broker & Technology Heads-Up:

The alerts generated by this script ({"secret": "...", "alertType": "multi_leg_order"...}) are specifically formatted for the DhanHQ webhook structure.

Dhan Users: Plug-and-play.
Other Brokers: You need middleware (NextLevelBot, Quantiply) to parse the JSON.

Risk Disclaimer & Advice

Trading options involves substantial risk.

The Whipsaw Risk: In Phase 2, you are Long Calls and Short Puts. A sharp reversal causes losses on both sides.
Margin: Selling options requires significant margin. Keep a 15-20% cash buffer to handle adjustments instantly.

Testing: This strategy is optimized for NIFTY Weekly Options. Effectiveness on BankNifty or Stocks is untested and may require parameter tuning.


Advice:

Backtest: Use TradingView Replay.
Paper Trade: Run for at least one expiry cycle before live deployment.
Consult: Seek professional financial advice before trading.

Practical Tips for Smooth Execution

For a new trader deploying this system, these operational tips are vital:

Capital Buffer: Do not trade at your limit. Always keep 10-15% free cash in your broker account. Adjustments (specifically Phase 2, where you sell an extra Put) require additional margin instantly. If margin is short, the order fails, and your hedge breaks.

Liquidity Awareness: The script trades "Far Deep OTM" options (Leg 4) to reduce margin. On indices like Nifty/BankNifty, this is fine. On individual stocks, these deep strikes might be illiquid. Check the option chain volume before deploying on stocks.

Trust the Process (but Verify): While the algo drives, you are the pilot.
  1. Check your API connection every morning.
  2. Ensure the "Entry Window" background color on the chart matches your real-world date.
  3. Verify that your broker executed all legs of a multi-leg order (partial fills are rare but possible).


The "Human" Stop: If major news breaks (e.g., unexpected election results, war announcements), volatility can expand faster than any algo can react. It is acceptable—and smart—to pause the strategy during known "Black Swan" events or earnings releases.

Timeframe Selection: The 30-Minute Standard

Critical Requirement: This indicator must be applied to a 30-minute chart.

Why?

Noise Filtering: The Supertrend logic is tuned to capture multi-day trends. Lower timeframes (5m, 15m) are full of "noise"—random fluctuations that look like trend changes but aren't.

Execution Logic (The Hybrid Engine): The script has a built-in "Dual Timeframe" architecture.

Decision Layer (30m): Uses the chart timeframe to decide when to be Bullish or Bearish.

Execution Layer (5m): Internally fetches 5-minute data to manage the how (Adjustments, Late Entries, and precise invalidation).

The Risk of Lower Timeframes: If you run the main chart on 5-minutes, you destroy this hierarchy. You will get too many signals, pay too much brokerage, and the internal logic may behave erratically.

Recommendation: Always keep your TradingView chart interval at 30m. Do not switch to lower timeframes expecting "faster" signals; you will likely just get "false" signals.

Testing Scope, Feedback

⚠️ Important Note on Asset Classes:

This strategy logic and the associated strike step calculations have been rigorously tested ONLY on NIFTY Index Options with Weekly Expiry.

BankNifty / Sensex / FinNifty: The volatility characteristics (ATR) and strike intervals of these instruments differ significantly from NIFTY. The effectiveness of this strategy on these other scripts has not been verified and may require different parameter tuning (e.g., strike_step or ATR Length).

Stocks: Individual stock options often lack the liquidity required for the "Deep OTM" legs, leading to potential execution failures.

We encourage traders to backtest this logic on other indices and share their findings! If you find a robust parameter set for BankNifty or observe unique behaviors on other scripts, please let us know in the comments below so we can improve the algorithm for everyone. Your feedback is appriciated.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน