OPEN-SOURCE SCRIPT

Strategy SuperTrend SDI Webhook

233
This Pine Script™ strategy is designed for automated trading in TradingView. It combines the SuperTrend indicator and Smoothed Directional Indicator (SDI) to generate buy and sell signals, with additional risk management features like stop loss, take profit, and trailing stop. The script also includes settings for leverage trading, equity-based position sizing, and webhook integration.

Key Features
1. Date-based Trade Execution
The strategy is active only between the start and end dates set by the user.
times ensures that trades occur only within this predefined time range.
2. Position Sizing and Leverage
Uses leverage trading to adjust position size dynamically based on initial equity.
The user can set leverage (leverage) and percentage of equity (usdprcnt).
The position size is calculated dynamically (initial_capital) based on account performance.
3. Take Profit, Stop Loss, and Trailing Stop
Take Profit (tp): Defines the target profit percentage.
Stop Loss (sl): Defines the maximum allowable loss per trade.
Trailing Stop (tr): Adjusts dynamically based on trade performance to lock in profits.
4. SuperTrend Indicator
SuperTrend (ta.supertrend) is used to determine the market trend.
If the price is above the SuperTrend line, it indicates an uptrend (bullish).
If the price is below the SuperTrend line, it signals a downtrend (bearish).
Plots visual indicators (green/red lines and circles) to show trend changes.
5. Smoothed Directional Indicator (SDI)
SDI helps to identify trend strength and momentum.
It calculates +DI (bullish strength) and -DI (bearish strength).
If +DI is higher than -DI, the market is considered bullish.
If -DI is higher than +DI, the market is considered bearish.
The background color changes based on the SDI signal.
6. Buy & Sell Conditions
Long Entry (Buy) Conditions:
SDI confirms an uptrend (+DI > -DI).
SuperTrend confirms an uptrend (price crosses above the SuperTrend line).
Short Entry (Sell) Conditions:
SDI confirms a downtrend (+DI < -DI).
SuperTrend confirms a downtrend (price crosses below the SuperTrend line).
Optionally, trades can be filtered using crossovers (occrs option).
7. Trade Execution and Exits
Market entries:
Long (strategy.entry("Long")) when conditions match.
Short (strategy.entry("Short")) when bearish conditions are met.
Trade exits:
Uses predefined take profit, stop loss, and trailing stop levels.
Positions are closed if the strategy is out of the valid time range.

Usage
Automated Trading Strategy:
Can be integrated with webhooks for automated execution on supported trading platforms.
Trend-Following Strategy:
Uses SuperTrend & SDI to identify trend direction and strength.
Risk-Managed Leverage Trading:
Supports position sizing, stop losses, and trailing stops.
Backtesting & Optimization:
Can be used for historical performance analysis before deploying live.

Conclusion
This strategy is suitable for traders who want to automate their trading using SuperTrend and SDI indicators. It incorporates risk management tools like stop loss, take profit, and trailing stop, making it adaptable for leverage trading. Traders can customize settings, conduct backtests, and integrate it with webhooks for real-time trade execution. 🚀

Important Note:
This script is provided for educational and template purposes and does not constitute financial advice. Traders and investors should conduct their research and analysis before making any trading decisions.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.