OPEN-SOURCE SCRIPT

# Multi-Step Vegas SuperTrend - strategy [presentTrading]

Long time no see! I am back : ) Please allow me to gain some warm-up.

█ Introduction and How it is Different

The "Vegas SuperTrend Strategy" is an enhanced trading strategy that leverages both the Vegas Channel and SuperTrend indicators to generate buy and sell signals.

What sets this strategy apart from others is its dynamic adjustment to market volatility and its multi-step take profit mechanism. Unlike traditional single-step profit-taking approaches, this strategy allows traders to systematically scale out of positions at predefined profit levels, thereby optimizing their risk-reward ratio and maximizing potential gains.

BTCUSD 6hr performance

█ Strategy, How it Works: Detailed Explanation

The Vegas SuperTrend Strategy combines the strengths of the Vegas Channel and SuperTrend indicators to identify market trends and generate trade signals. The following subsections delve into the details of how each component works and how they are integrated.

🔶 Vegas Channel Calculation

The Vegas Channel is based on a simple moving average (SMA) and the standard deviation (STD) of the closing prices over a specified period. The channel is defined by upper and lower bounds that are dynamically adjusted based on market volatility.

Simple Moving Average (SMA):
SMA_vegas = (1/N) * Σ(Close_i) for i = 0 to N-1
where N is the length of the Vegas Window.

Standard Deviation (STD):
STD_vegas = sqrt((1/N) * Σ(Close_i - SMA_vegas)^2) for i = 0 to N-1

Vegas Channel Upper and Lower Bounds:
VegasChannelUpper = SMA_vegas + STD_vegas
VegasChannelLower = SMA_vegas - STD_vegas

The details are here:

🔶 Trend Detection and Trade Signals

The strategy determines the current market trend based on the closing price relative to the SuperTrend bounds:

Market Trend:
MarketTrend = 1 if Close > SuperTrendPrevLower
-1 if Close < SuperTrendPrevUpper
Previous Trend otherwise

Trade signals are generated when there is a shift in the market trend:
Bullish Signal: When the market trend shifts from -1 to 1.
Bearish Signal: When the market trend shifts from 1 to -1.

🔶 Multi-Step Take Profit Mechanism

The strategy incorporates a multi-step take profit mechanism that allows for partial exits at predefined profit levels. This helps in locking in profits gradually and reducing exposure to market reversals.

Take Profit Levels:
The take profit levels are calculated as percentages of the entry price:
TakeProfitLevel_i = EntryPrice * (1 + TakeProfitPercent_i/100) for long positions
TakeProfitLevel_i = EntryPrice * (1 - TakeProfitPercent_i/100) for short positions

Multi-steps take profit local picture:

The trade direction can be customized based on the user's preference:
Long: The strategy only takes long positions.
Short: The strategy only takes short positions.
Both: The strategy can take both long and short positions based on the market trend.

█ Usage

To use the Vegas SuperTrend Strategy, follow these steps:

Configure Input Settings:
- Set the ATR period, Vegas Window length, SuperTrend Multiplier, and Volatility Adjustment Factor.
- Choose the desired trade direction (Long, Short, Both).
- Enable or disable the take profit mechanism and set the take profit percentages and amounts for each step.

█ Default Settings

The default settings of the strategy are designed to provide a balanced approach to trading. Below is an explanation of each setting and its effect on the strategy's performance:

ATR Period (10): This setting determines the length of the ATR used in the SuperTrend calculation. A longer period smoothens the ATR, making the SuperTrend less sensitive to short-term volatility. A shorter period makes the SuperTrend more responsive to recent price movements.

Vegas Window Length (100): This setting defines the period for the Vegas Channel's moving average. A longer window provides a broader view of the market trend, while a shorter window makes the channel more responsive to recent price changes.

SuperTrend Multiplier (5): This base multiplier adjusts the sensitivity of the SuperTrend to the ATR. A higher multiplier makes the SuperTrend less sensitive, reducing the frequency of trade signals. A lower multiplier increases sensitivity, generating more signals.

Volatility Adjustment Factor (5): This factor dynamically adjusts the SuperTrend multiplier based on the width of the Vegas Channel. A higher factor increases the sensitivity of the SuperTrend to changes in market volatility, while a lower factor reduces it.

Take Profit Percentages (3.0%, 6.0%, 12.0%, 21.0%): These settings define the profit levels at which portions of the trade are exited. They help in locking in profits progressively as the trade moves in favor.

Take Profit Amounts (25%, 20%, 10%, 15%): These settings determine the percentage of the position to exit at each take profit level. They are distributed to ensure that significant portions of the trade are closed as the price reaches the set levels, reducing exposure to reversals.

Adjusting these settings can significantly impact the strategy's performance. For instance, increasing the ATR period or the SuperTrend multiplier can reduce the number of trades, potentially improving the win rate but also missing out on some profitable opportunities. Conversely, lowering these values can increase trade frequency, capturing more short-term movements but also increasing the risk of false signals.