Dynamic Trading with RSI Divergence and Moving Averages
This script implements a sophisticated trading strategy that merges box range detection, RSI divergence signals, and moving average trend analysis—optimized for OKX Signal Bots. Below are its core functionalities:
Key Features:
Box Range Detection
- Identifies price ranges using highest highs and lowest lows within a configurable
boxLengthperiod. - Visualizes these levels on charts for clear price-range analysis.
- Identifies price ranges using highest highs and lowest lows within a configurable
RSI Divergence Detection
- Calculates RSI using adjustable
rsiLength. - Detects bullish divergence (price lower low + RSI higher low) and bearish divergence (price higher high + RSI lower high).
- Customizable lookback periods (
leftLookback,rightLookback) for precise extremum identification.
- Calculates RSI using adjustable
Moving Average Integration
- Supports multiple MA types: SMA, EMA, SMMА, WMA, VWMA.
- Plots MA20, MA50, MA100, and MA200 on user-defined timeframes (
custom_timeframe). - Filters signals based on trend alignment (e.g., long signals only in downtrends).
Dynamic Position Management
- Adjusts position sizes based on price deviation from
avgPrice. - Configurable thresholds (
minEnterPercent,minExitPercent) for partial entries/exits.
- Adjusts position sizes based on price deviation from
OKX Bot Integration
- Sends buy/sell signals via
signalToken. - Supports market/limit orders with price offsets.
- Sends buy/sell signals via
OKX Signal Bot: Strategy Scanner & Order Designer
A tool to design, scan, and execute strategies across 20+ cryptocurrencies on OKX futures.
Step-by-Step Setup:
OKX Account Setup
- Log into OKX and create a Signal Bot.
- Note the webhook URL and signal token.
Strategy Configuration
- Add trading pairs (ensure symbols end with
.Pfor futures). - Define entry conditions (LONG/SHORT) using AND/OR logic.
- Add trading pairs (ensure symbols end with
Indicator Linking
- Paste your
signalTokeninto the script’s OKX Signal ID field. - Set alarms with the webhook URL for automated signal dispatch.
- Paste your
⚠️ Note:
- Exclusively for futures trading.
- Leverage, TP/SL must be set via OKX.
- Avoid excessive alerts to prevent TradingView restrictions.
Turtle Trade Channels Indicator (TUTCI)
A breakout-based system inspired by the 80% annual-return Turtle Trading strategy.
Core Principles:
- Entry: Buy at 20-day highs / Sell at 20-day lows (Donchian Channels).
- Exit: Close positions at 10-day highs/lows to lock profits.
How TUTCI Works:
- Trend Line (Red): Uptrend when price bars are above; downtrend below.
- Exit Line (Blue Dotted): Signals position closure at 10-day extremes.
FAQ Section
1. How does RSI divergence improve trade accuracy?
Divergences signal potential reversals—bullish when price falls but RSI rises, and vice versa. Combined with MAs, they filter high-probability trades.
2. Can I use these scripts for spot trading?
No. These templates are designed for OKX futures (symbols ending in .P).
3. What’s the risk management approach?
Dynamic position scaling and trend filters minimize losses. Always set stop-losses via OKX.
4. How do I avoid TradingView alert bans?
Limit alerts to critical signals (e.g., 1–2 per day per pair).
5. Are these strategies profitable in sideways markets?
Box range detection performs best in ranging markets, while TUTCI excels in trending conditions.
Disclaimer: These scripts are templates for OKX alert integration—not financial advice. Cryptocurrency trading carries high risk. Past performance ≠ future results. Consult a financial advisor.