TradingView
PresentTrading
1 Jan 2024 pukul 02.40

FlexiSuperTrend - Strategy [presentTrading] 

Bitcoin / DollarBitfinex

Deskripsi

█ Introduction and How it is Different

The "FlexiSuperTrend - Strategy" by PresentTrading is a cutting-edge trading strategy that redefines market analysis through the integration of the SuperTrend indicator and advanced variance tracking.

BTC 6H L/S


This strategy stands apart from conventional methods by its dynamic adaptability, capturing market trends and momentum shifts with increased sensitivity. It's designed for traders seeking a more responsive tool to navigate complex market movements.

Local


█ Strategy, How It Works: Detailed Explanation

The "FlexiSuperTrend - Strategy" employs a multifaceted approach, combining the adaptability of the SuperTrend indicator with variance tracking. The strategy's core lies in its unique formulation and application of these components:

🔶 SuperTrend Polyfactor Oscillator:
- Basic Concept: The oscillator is a series of SuperTrend calculations with varying ATR lengths and multipliers. This approach provides a broader and more nuanced perspective of market trends.
- Calculation:
- For each iteration, `i`, the SuperTrend is calculated using:
- `ATR Length = indicatorLength * (startingFactor + i * incrementFactor)`.
- `Multiplier = dynamically adjusted based on market conditions`.
- The SuperTrend output for each iteration is compared with the indicator source (like hlc3), and the deviation is recorded.

SuperTrend Calculation:
- `Upper Band (UB) = hl2 + (ATR Length * Multiplier)`
- `Lower Band (LB) = hl2 - (ATR Length * Multiplier)`
- Where `hl2` is the average of high and low prices.

Deviation Calculation:
- `Deviation = indicatorSource - SuperTrend Value`
- This value is calculated for each SuperTrend setting in the oscillator series.

🔶 Indicator Source (`hlc3`):
- **Usage:** The strategy uses the average of high, low, and close prices, providing a balanced representation of market activity.

🔶 Adaptive ATR Lengths and Factors:
- Dynamic Adjustment: The strategy adjusts the ATR length and multiplier based on the `startingFactor` and `incrementFactor`. This adaptability is key in responding to changing market volatilities.
- Equation: ATR Length at each iteration `i` is given by `len = indicatorLength * (startingFactor + i * incrementFactor)`.

incrementFactor - 1


incrementFactor - 2


🔶 Normalization Methods:
Purpose: To standardize the deviations for comparability.
- Methods:
- 'Max-Min': Scales the deviation based on the range of values.
- 'Absolute Sum': Uses the sum of absolute deviations for normalization.

Normalization 'Absolute Sum'


- For 'Max-Min': `Normalized Deviation = (Deviation - Min(Deviations)) / (Max(Deviations) - Min(Deviations))`
- For 'Absolute Sum': `Normalized Deviation = Deviation / Sum(Absolute(Deviations))`

🔶 Trading Logic:
The strategy integrates the SuperTrend indicator, renowned for its effectiveness in identifying trend direction and reversals. The SuperTrend's incorporation enhances the strategy's ability to filter out false signals and confirm genuine market trends. * The SuperTrend Toolkit is made by @QuantiLuxe
- Long Entry Conditions: A buy signal is generated when the current trend, as indicated by the SuperTrend Polyfactor Oscillator, turns positive.
- Short Entry Conditions: A sell signal is triggered when the current trend turns negative.
- Entry and Exit Strategy: The strategy opens or closes positions based on these signals, aligning with the selected trade direction (long, short, or both).


█ Trade Direction

The strategy is versatile, allowing traders to choose their preferred trading direction: long, short, or both. This flexibility enables traders to tailor their strategies to their market outlook and risk appetite.

█ Usage

The FlexiSuperTrend strategy is suitable for various market conditions and can be adapted to different asset classes and time frames. Traders should set the strategy parameters according to their risk tolerance and trading goals. It's particularly useful for capturing long-term movements, ideal for swing traders, yet adaptable for short-term trading strategies.

█ Default Settings

1. Trading Direction: Choose from "Long", "Short", or "Both" to define the trade type.
2. Indicator Source (HLC3): Utilizes the HLC3 as the primary price reference.
3. Indicator Length (Default: 10): Influences the moving average calculation and trend sensitivity.
4. Starting Factor (0.618): Initiates the ATR length, influenced by Fibonacci ratios.
5. Increment Factor (0.382): Adjusts the ATR length incrementally for dynamic trend tracking.
6. Normalization Method: Options include "None", "Max-Min", and "Absolute Sum" for scaling deviations.
7. SuperTrend Settings: Varied ATR lengths and multipliers tailor the indicator's responsiveness.
8. Additional Settings: Features mesh style plotting and customizable colors for visual distinction.

The default settings provide a balanced approach, but users are encouraged to adjust them based on their individual trading style and market analysis.

Catatan Rilis

Revise:
// Entry/Exit conditions
LongEntry = st.d < 0 and medianValue > 0
LongExit = st.d > 0
ShortEntry = st.d > 0 and medianValue < 0
ShortExit = st.d < 0

1. Long Entry Conditions: Activated when SuperTrend direction is negative (downward) and the median oscillator value is above zero.
2. Short Entry Conditions: Triggered when SuperTrend direction is positive (upward) and the median oscillator value is below zero.
3. Long Exit Conditions: Initiated when the SuperTrend direction turns positive, signaling a potential end to the upward trend.
4. Short Exit Conditions: Occur when the SuperTrend direction switches to negative, indicating a possible reversal from a downward trend.
Komentar
EliCobra
Cool idea, nice seeing the toolkit put to work.
PresentTrading
@EliCobra, you are one of the best script coders in Tradingview : )
screamonei
If you want to use in 3commas, just replace the entries and exits as it below (don't forget to add your own e-mail ID and bot ID).

// Strategy logic
if (tradeDirection == "Long" or tradeDirection == "Both")
if LongEntry
strategy.entry("Long Entry", strategy.long, comment = "{\n\"message_type\": \"bot\",\n\"bot_id\": ADD_YOURS,\n\"email_token\": \"ADD_YOURS1\",\n\"delay_seconds\": 0\n}")

if (tradeDirection == "Short" or tradeDirection == "Both")
if ShortEntry
strategy.entry("Short Entry", strategy.short, comment = "{\n\"message_type\": \"bot\",\n\"bot_id\": ADD_YOURS,\n\"email_token\": \"ADD_YOURS\",\n\"delay_seconds\": 0\n}")

if (tradeDirection == "Long" or tradeDirection == "Both")
if LongExit
strategy.close("Long Entry", comment = "{\n\"action\": \"close_at_market_price\",\n\"message_type\": \"bot\",\n\"bot_id\": ADD_YOURS,\n\"email_token\": \"ADD_YOURS\",\n\"delay_seconds\": 0\n}")

if (tradeDirection == "Short" or tradeDirection == "Both")
if ShortExit
strategy.close("Short Entry", comment = "{\n\"action\": \"close_at_market_price\",\n\"message_type\": \"bot\",\n\"bot_id\": ADD_YOURS,\n\"email_token\": \"ADD_YOURS\",\n\"delay_seconds\": 0\n}")
PresentTrading
@screamonei, greatt! thanks for sharing
screamonei
@screamonei, I just forgot to mention, using comments, you need to create a single alert for the strategy and just add in the message the {{strategy.order.comment}}. This way you don't have to make alerts for each action...
josephdooley92
@screamonei, how do i get the bot like copy and paste to 3comm
screamonei
Hi sir, thank you for this amazing strategy! I am facing some issues by trying to send a json to 3commas via "comment=" in the triggers. This is what I have:

// Strategy logic
if (tradeDirection == "Long" or tradeDirection == "Both")
if LongEntry
strategy.entry("Long Entry", strategy.long, comment = "{\n\”message_type\”: \”bot\”,\n\”bot_id\”: 1xxxxxx2,\n\”email_token\”: \”9xxxxxx1\”,\n\”delay_seconds\”: 0\n}")

if (tradeDirection == "Short" or tradeDirection == "Both")
if ShortEntry
strategy.entry("Short Entry", strategy.short, comment = "{\n\”message_type\”: \”bot\”,\n\”bot_id\”: 1xxxxxx2,\n\”email_token\”: \”9xxxxxx1\”,\n\”delay_seconds\”: 0\n}")

if (tradeDirection == "Long" or tradeDirection == "Both")
if LongExit
strategy.close("Long Entry", comment = "{\n\”action\”: \”close_at_market_price\”,\n\”message_type\”: \”bot\”,\n\”bot_id\”: 1xxxxxx2,\n\”email_token\”: \”9xxxxxx1\”,\n\”delay_seconds\”: 0\n}")

if (tradeDirection == "Short" or tradeDirection == "Both")
if ShortExit
strategy.close("Short Entry", comment = "{\n\”action\”: \”close_at_market_price\”,\n\”message_type\”: \”bot\”,\n\”bot_id\”: 1xxxxxx2,\n\”email_token\”: \”9xxxxxx1\”,\n\”delay_seconds\”: 0\n}")

I would be very thankful if you could help me on this!
PresentTrading
@screamonei, hey try to use the alert_message variable inside strategy.entry and strategy.close. you try one more time first. : )
Lebih lanjut