OPEN-SOURCE SCRIPT

Kaito Box with RSI Div(Dynamic Adjustment + MA + Long)

369
The script implements a dynamic trading strategy that combines box range detection, RSI divergence signals, and moving average trend analysis. It is designed for use on OKX Signal Bots and includes features for dynamic position scaling and partial position closing. Below is a summary of its key functionalities:
Key Features:
Box Range Detection:

The script identifies price ranges using the highest high and lowest low of a configurable boxLength period.
These levels are plotted on the chart to visualize the price range.
RSI Divergence Detection:

The script calculates RSI using a configurable rsiLength.
Detects bullish divergence when price makes a lower low, but RSI makes a higher low.
Detects bearish divergence when price makes a higher high, but RSI makes a lower high.
Includes separate left and right lookback periods (leftLookback, rightLookback) for precise local extrema detection.
Customizable Moving Averages:

Supports multiple types of Moving Averages (SMA, EMA, SMMA, WMA, VWMA).
Calculates and plots MA20, MA50, MA100, and MA200 on a user-defined timeframe (custom_timeframe).
Identifies uptrends and downtrends based on the alignment of the moving averages and price levels.
Dynamic Position Scaling:

Implements dynamic position sizing for long entries and partial position closing for exits.
The percentage of position size added or closed is based on the difference between the current price and the average position price (avgPrice), with configurable minimum thresholds (minEnterPercent, minExitPercent).
Signal Integration for OKX Bots:

Sends buy/sell signals to OKX Signal Bots using the configured signalToken.
Supports market or limit orders with configurable price offsets and investment types.
Trend-Based Signal Filtering:

Only triggers long signals during downtrends and short signals during uptrends, ensuring trades align with the overall market context.
Visual Annotations:

Plots bullish and bearish divergence signals on the chart.
Displays labels showing dynamic position size adjustments and current average price during trades.
How It Works:
Long Signals:

Triggered when the price breaches the lower box range, and a bullish RSI divergence is detected.
Additional filtering ensures long trades are executed only during downtrend conditions.
Dynamically adjusts the position size based on the price difference from the average entry price.
Short Signals:

Triggered when the price breaches the upper box range, and a bearish RSI divergence is detected.
Additional filtering ensures short trades are executed only during uptrend conditions.
Dynamically closes portions of the position based on price movement relative to the average entry price.
Alerts:

Generates actionable alerts formatted for OKX bots, including order type, signal token, and dynamically calculated position sizes.
Use Case:
This strategy is well-suited for automated trading on platforms like OKX, where it can:

Exploit price ranges and RSI divergences for precise entries and exits.
Dynamically manage position sizes to optimize risk-reward.
Adapt to different market conditions using configurable parameters like moving averages, divergence lookbacks, and trend filters.
This script provides a robust foundation for traders looking to automate their strategies while maintaining flexibility and control over their trading logic.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.