OPEN-SOURCE SCRIPT
Atualizado

Algoticks.in: Supertrend Strategy (Directional option sample)

37
Supertrend Strategy - User Guide

Overview
This is a trend-following strategy based on the Supertrend indicator. It generates signals when the trend direction changes (Green to Red or Red to Green). It is fully integrated with Algoticks.in API for automated trading on Delta Exchange, with specialized logic for Options trading.

Strategy Logic
  • Long Signal: When Supertrend flips to Green (Bullish Trend Start)
  • Short Signal: When Supertrend flips to Red (Bearish Trend Start)
  • Automatically closes opposite positions before entering new ones


Quick Setup

1. Add to TradingView
  1. Open TradingView and go to the chart
  2. Click "Pine Editor" at the bottom
  3. Paste the script code
  4. Click "Add to Chart"


2. Configure Strategy Parameters

Strategy Settings
  • ATR Length (default: 10): The lookback period for Average True Range
  • Factor (default: 3.0): The multiplier for the ATR bands. Higher values = fewer signals (less noise), Lower values = more signals (scalping).


General API Settings
  • Paper Trading: Enable for testing without real money
  • Signal Type: Choose "Trading Signal" (default) for tracking
  • Exchange: DELTA (Delta Exchange)
  • Segment:
    • futures - Perpetual contracts
    • options - Call/Put options
    • spot - Spot trading


Order Settings: Basic
  • Quantity: Number of contracts (e.g., 1, 0.5, 2)
  • Validity:
    GTC - Good Till Cancelled
    IOC - Immediate or Cancel
    FOK - Fill or Kill
    DAY - Day order
  • Product: cross_margin or isolated_margin


Order Settings: Entry Type
Choose how orders are executed:
  • Market Order: Immediate fill at best price
  • Limit Order: Fill at specified price or better
  • Stop Market: Triggers at stop price, then market order
  • Stop Limit: Triggers at stop price, then limit order


Entry Prices (for Limit/Stop orders)

Limit Price:
  • Price: The value to use
  • Type: Last Price / Mark Price / Index Price
  • Mode:
    Absolute - Exact price (e.g., 65000)
    Relative - Offset from entry price
  • % Checkbox: If checked, relative uses percentage; if unchecked, uses points


Example:
  • Absolute: 65000 → Order at exactly 65000
  • Relative 1% (checked): Entry ± 1% of entry price
  • Relative 100 (unchecked): Entry ± 100 points


Trigger Price: Same logic as Limit Price, used for Stop orders

Exit / Bracket Prices (SL/TP)

Stop Loss (SL):
  • Type: Price type to monitor (Mark Price recommended)
  • Mode: Absolute or Relative
  • %: Percentage or points
  • SL: Stop loss value (e.g., 2 for 2%)
  • Trig: Optional trigger price (creates Stop-Limit SL)


Take Profit (TP): Same structure as SL

Example:
  • Long entry at 65000, SL = 2% → Exit at 63700 (65000 - 2%)
  • Short entry at 65000, TP = 3% → Exit at 63050 (65000 - 3%)


3. Options Trading Setup (CRITICAL)

This strategy has special logic for Options trading to handle directional bias correctly.

Scenario A: Options Buying (Long Volatility)
You want to BUY Calls when the trend is Up, and BUY Puts when the trend is Down.
  • Segment: options
  • Strike Selection: Dynamic
  • Algo Type: Options Buying Algo

What happens:
  • Long Signal (Green Supertrend) → System sends BUY action. Backend buys a Call (CE).
  • Short Signal (Red Supertrend) → System sends BUY action. Backend buys a Put (PE).


Scenario B: Options Selling (Short Volatility)
You want to SELL Puts when the trend is Up (Bullish), and SELL Calls when the trend is Down (Bearish).
  • Segment: options
  • Strike Selection: Dynamic
  • Algo Type: Options Selling Algo

What happens:
  • Long Signal (Green Supertrend) → System sends SELL action. Backend sells a Put (PE).
  • Short Signal (Red Supertrend) → System sends SELL action. Backend sells a Call (CE).


Dynamic Strike Settings:
  • Strike Offset: 0 (ATM), +1 (OTM for Calls/ITM for Puts), -1 (ITM for Calls/OTM for Puts)
  • Strike Interval: Gap between strikes (e.g., BTC: 500, ETH: 50)


Expiry Date Formats:
  • T+0 - Today
  • T+1 - Tomorrow
  • current week - This Friday
  • next week - Next Friday
  • current month - Last Friday of month
  • 131125 - Specific date (13 Nov 2025)


4. Create Alert for Automation
  1. Right-click on chart → "Add Alert"
  2. Condition: Select your strategy name
  3. Alert Actions: Webhook URL
  4. Webhook URL: Your Algoticks.in API endpoint
  5. Message: Leave as {{strategy.order.alert_message}} (contains JSON)
  6. Click "Create"


The alert will automatically send JSON payloads to your API when signals occur.

Example Configurations

Futures Trend Following
[code]
Strategy: ATR=10, Factor=3.0
Segment: futures
Order Type: market_order
Quantity: 1
SL: 2% (Relative)
TP: 6% (Relative)
[/code]

Options Buying (Directional)
[code]
Segment: options
Strike Selection: Dynamic
Algo Type: Options Buying Algo
Strike Offset: 0 (ATM)
Strike Interval: 500 (for BTC)
Expiry: current week
Order Type: market_order
[/code]

Important Notes
  1. Paper Trading First: Always test with paper trading enabled before live trading
  2. Order Tags: Automatically generated for tracking (max 18 chars)
  3. Position Management: Strategy closes opposite positions automatically
  4. Signal Confirmation: Uses barstate.isconfirmed to prevent repainting
  5. JSON Payload: All settings are converted to JSON and sent via webhook


Troubleshooting
  • No signals: Check if Supertrend is flipping on your timeframe
  • Orders not executing: Verify webhook URL and API credentials
  • Wrong strikes: Double-check Strike Interval for your asset
  • SL/TP not working: Ensure values are non-zero and mode is correct


Support
For API setup and connector configuration, see visit Algoticks.in documentation.
Notas de Lançamento
Supertrend Strategy - User Guide

Overview
This is a trend-following strategy based on the Supertrend indicator. It generates signals when the trend direction changes (Green to Red or Red to Green). It is fully integrated with Algoticks.in API for automated trading on Delta Exchange, with specialized logic for Options trading.

Strategy Logic
  • Long Signal: When Supertrend flips to Green (Bullish Trend Start)
  • Short Signal: When Supertrend flips to Red (Bearish Trend Start)
  • Automatically closes opposite positions before entering new ones


Quick Setup

1. Add to TradingView
  1. Open TradingView and go to the chart
  2. Click "Pine Editor" at the bottom
  3. Paste the script code
  4. Click "Add to Chart"


2. Configure Strategy Parameters

Strategy Settings
  • ATR Length (default: 10): The lookback period for Average True Range
  • Factor (default: 3.0): The multiplier for the ATR bands. Higher values = fewer signals (less noise), Lower values = more signals (scalping).


General API Settings
  • Paper Trading: Enable for testing without real money
  • Signal Type: Choose "Trading Signal" (default) for tracking
  • Exchange: DELTA (Delta Exchange)
  • Segment:
    • futures - Perpetual contracts
    • options - Call/Put options
    • spot - Spot trading


Order Settings: Basic
  • Quantity: Number of contracts (e.g., 1, 0.5, 2)
  • Validity:
    GTC - Good Till Cancelled
    IOC - Immediate or Cancel
    FOK - Fill or Kill
    DAY - Day order
  • Product: cross_margin or isolated_margin


Order Settings: Entry Type
Choose how orders are executed:
  • Market Order: Immediate fill at best price
  • Limit Order: Fill at specified price or better
  • Stop Market: Triggers at stop price, then market order
  • Stop Limit: Triggers at stop price, then limit order


Entry Prices (for Limit/Stop orders)

Limit Price:
  • Price: The value to use
  • Type: Last Price / Mark Price / Index Price
  • Mode:
    Absolute - Exact price (e.g., 65000)
    Relative - Offset from entry price
  • % Checkbox: If checked, relative uses percentage; if unchecked, uses points


Example:
  • Absolute: 65000 → Order at exactly 65000
  • Relative 1% (checked): Entry ± 1% of entry price
  • Relative 100 (unchecked): Entry ± 100 points


Trigger Price: Same logic as Limit Price, used for Stop orders

Exit / Bracket Prices (SL/TP)

Stop Loss (SL):
  • Type: Price type to monitor (Mark Price recommended)
  • Mode: Absolute or Relative
  • %: Percentage or points
  • SL: Stop loss value (e.g., 2 for 2%)
  • Trig: Optional trigger price (creates Stop-Limit SL)


Take Profit (TP): Same structure as SL

Example:
  • Long entry at 65000, SL = 2% → Exit at 63700 (65000 - 2%)
  • Short entry at 65000, TP = 3% → Exit at 63050 (65000 - 3%)


3. Options Trading Setup (CRITICAL)

This strategy has special logic for Options trading to handle directional bias correctly.

Scenario A: Options Buying (Long Volatility)
You want to BUY Calls when the trend is Up, and BUY Puts when the trend is Down.
  • Segment: options
  • Strike Selection: Dynamic
  • Algo Type: Options Buying Algo

What happens:
  • Long Signal (Green Supertrend) → System sends BUY action. Backend buys a Call (CE).
  • Short Signal (Red Supertrend) → System sends BUY action. Backend buys a Put (PE).


Scenario B: Options Selling (Short Volatility)
You want to SELL Puts when the trend is Up (Bullish), and SELL Calls when the trend is Down (Bearish).
  • Segment: options
  • Strike Selection: Dynamic
  • Algo Type: Options Selling Algo

What happens:
  • Long Signal (Green Supertrend) → System sends SELL action. Backend sells a Put (PE).
  • Short Signal (Red Supertrend) → System sends SELL action. Backend sells a Call (CE).


Dynamic Strike Settings:
  • Strike Offset: 0 (ATM), +1 (OTM for Calls/ITM for Puts), -1 (ITM for Calls/OTM for Puts)
  • Strike Interval: Gap between strikes (e.g., BTC: 500, ETH: 50)


Expiry Date Formats:
  • T+0 - Today
  • T+1 - Tomorrow
  • current week - This Friday
  • next week - Next Friday
  • current month - Last Friday of month
  • 131125 - Specific date (13 Nov 2025)


4. Create Alert for Automation
  1. Right-click on chart → "Add Alert"
  2. Condition: Select your strategy name
  3. Alert Actions: Webhook URL
  4. Webhook URL: Your Algoticks.in API endpoint
  5. Message: Leave as {{strategy.order.alert_message}} (contains JSON)
  6. Click "Create"


The alert will automatically send JSON payloads to your API when signals occur.

Example Configurations

Futures Trend Following
[code]
Strategy: ATR=10, Factor=3.0
Segment: futures
Order Type: market_order
Quantity: 1
SL: 2% (Relative)
TP: 6% (Relative)
[/code]

Options Buying (Directional)
[code]
Segment: options
Strike Selection: Dynamic
Algo Type: Options Buying Algo
Strike Offset: 0 (ATM)
Strike Interval: 500 (for BTC)
Expiry: current week
Order Type: market_order
[/code]

Important Notes
  1. Paper Trading First: Always test with paper trading enabled before live trading
  2. Order Tags: Automatically generated for tracking (max 18 chars)
  3. Position Management: Strategy closes opposite positions automatically
  4. Signal Confirmation: Uses barstate.isconfirmed to prevent repainting
  5. JSON Payload: All settings are converted to JSON and sent via webhook


Troubleshooting
  • No signals: Check if Supertrend is flipping on your timeframe
  • Orders not executing: Verify webhook URL and API credentials
  • Wrong strikes: Double-check Strike Interval for your asset
  • SL/TP not working: Ensure values are non-zero and mode is correct


Support
For API setup and connector configuration, visit Algoticks.in documentation.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.