OPEN-SOURCE SCRIPT

Strategy / Connectable [Azullian]

Mis à jour
The connectable strategy serves as a foundational component in our indicator system on TradingView, designed for intuitive testing, visualization, and construction of trading strategies. In concert with the connectable signal filter, it forms a cohesive unit that allows for efficient signal processing and strategy implementation. This integration enables the strategy to receive and act on weighted signals from various connectable indicators, making it a versatile tool for both novice and experienced traders.

Let's review the separate parts of this indicator.

█ STRATEGY INPUTS

We've provided an input to connect a signal filter or indicators or chains (→) which is set to 'Close' by default.

snapshot

An input has several controls:
 • Input: Connect indicators or signal filter here, choose indicators with a compatible : Signal connector.
 • SM - Signal Mode: Choose a trading direction compatible with the settings in your signal filter



POSITION INVESTMENT
Determine the percentage of your trading budget you would like to use in each position based on the strategy's profit or loss.

snapshot

 • LINVB - Loss Investment Base: Choose which base to use to determine the investment percentage when the strategy is in a loss.
    ○ Equity: Use the equity as the base for percentage calculation.
    ○ Initial capital: Use the initial capital as the base for percentage calculation.
 • LINV% - Loss Investment Percentage: Set a percentage of the chosen investment base as the investment for a new position.
    ○ For example, when 10% in loss, and a initial capital of $100, and the investment base is set to equity with a percentage of 50%, your investment will be 50% of $90, $45.

 • PINVB - Profit Investment Base: Choose which base to use to determine the investment percentage when the strategy is in profit.
    ○ Equity: Use the equity as the base for percentage calculation.
    ○ Initial capital: Use the initial capital as the base for percentage calculation.
 • PINV% - Profit Investment Percentage: Set a percentage of the chosen investment base as the investment for a new position.
    ○ For example, when 10% in profit, and an initial capital of $100, and the investment base is set to equity with a percentage of 100%, your investment will be 100% of $110, $110.

 • RISK% - Risk Percentage:
    ○ Determine how much of the calculated position investment is at risk when the stop-loss is hit.
        - For example, 1% of $45 represents a maximum loss of $0.45.
    ○ Risk percentage works together with the stop loss and the max leverage.
 • MXLVG - Maximum Leverage:
    ○ Investigate the trading rules for your trading pair and use the maximum allowed amount of leverage.
    ○ To determine the number of contracts to be bought or sold, considering the stop loss and the specified risk percentage, the maximum leverage available will constrain the amount of leverage utilized to ensure that the maximum risk threshold is not exceeded. For instance, suppose the stop loss is set at 1%, and the risk percentage is defined as 10%. Initially, the calculated leverage to be used would be 10. However, if there is a maximum leverage cap set at 5, it would constrain the calculated leverage of 10 to adhere to the maximum limit of 5.



EXIT STOP LOSS
Determine the Stop Loss price based on your selected configuration.
As the stop loss is an integral part of the ordered contracts calculation used in conjunction with the Risk and Max leverage, you'll always need to provide a stop loss price.

snapshot

 • SLB - Stop Loss Base: Choose a stop loss mode for calculating stop loss prices.
    ○ Risk: Determines the price using the Risk parameter (RISK%) and maximum leverage (MXLVG). In this case, SLB% will not have any impact.
    ○ Price Entry + Offset: Calculates the stop loss price based on a offset percentage (SLB%) from the entry price of the position.

 • SLB% - Stop Loss Base Percentage: Define an offset percentage that will be applied in the price entry + offset stop loss mode.

 • SLT - Stop Loss Trailing:
    ○ Fixed: The initial stop loss will be kept and no trailing stop loss will be applied.
    ○ Trail Price: Computes the trailing stop loss price based on an offset percentage (SLT%) from the closing price of the current candle.
        - If a better stop loss price is calculated, it will be set as the new stop loss price.
    ○ Trail Incr: Adapts the trailing stop loss price based on the offset percentage (SLT%).
        - Each price change in favor of your position will incrementally adapt the trailing stop loss with SLT%.
 • SLT% - Stop Loss Trailing Percentage: This percentage serves as an offset or increment depending on your chosen trailing mode.




EXIT TAKE PROFIT
Determine the Take Profit price based on your selected configuration.

snapshot

 • TPB - Take Profit Base: Choose a take profit mode for calculating take profit prices.
    ○ Reward: Determines the take profit price using the Risk parameter (RISK%) and the calculated Stop Loss price and the set reward percentage (TPB%).
        - For example: Risk 1%, Calculated Stop loss price: $90, Entry price: $100, Reward (TPB%): 2%, will result in a take profit price on $120.
    ○ Price Entry + Offset: Calculates the take profit price based on a offset percentage (TPB%) from the entry price of the position.
        - For example: Entry price: $100, Offset (TPB%): 2%, will result in a take profit price on $102.

 • TPB% - Take Profit Base Percentage: Define an offset percentage that will be applied in the price entry + offset take profit mode.

 • TPT - Take Profit Trailing:
    ○ Fixed: The initial take profit will be kept and no trailing take profit will be applied.
    ○ Trail Price: Computes the trailing take profit price based on an offset percentage (TPT%) from the closing price of the current candle.
        - If an applicable take profit price is calculated, it will be set as the new take profit price.
    ○ Trail Incr: Adapts the trailing take profit price based on the offset percentage (TPT%). Each price change against your position will incrementally adapt the trailing take profit with TPT%.
 • TPT% - Take Profit Trailing Percentage: This percentage serves as an offset or increment depending on your chosen trailing mode.




█ STRATEGY CONDITIONS

Specify when the strategy is permitted to execute trades.

snapshot

 • DATE: Enable the Date Range filter to restrict entries to a specific date range.
    ○ START: Set a start date and hour to commence trading.
    ○ END: Set an end date and hour to conclude trading within the defined range.



VISUALS

snapshot

 • LINE: Activate a colored dashed diagonal line to visually connect the entry and exit points of positions.
 • SLTP: Enable visualization of stop loss, take profit, and break-even levels.
 • PNL: Enable Break-Even and Close Lines along with a colored area in between to visualize profit and loss.

 • ☼: Brightness % : Adjust the opacity of the plotted trading visuals.
 • P - Profit Color : Choose the color for profit-related elements.
 • L - Loss Color: Choose the color for loss-related elements.
 • B - Breakeven Color : Select the color for break-even points.
 • EL - Long Color: Specify the color for long positions.
 • ES - Short Color: Specify the color for short positions.

 • TRADE LABELING: For better analysis we've labeled all entries and exits conform with the type of order your strategy has executed, some examples:
    ○ XL-TP-150: Exit Long - Take Profit - Position 150
    ○ XS-TP-154: Exit Short - Take Profit - Position 154
    ○ XL-SL-160: Exit Long - Stop Loss - Position 160
    ○ XS-SL-164: Exit Short - Stop Loss - Position 164



USAGE OF CONNECTABLE INDICATORS

 ■ Connectable chaining mechanism

Connectable indicators can be connected directly to the signal monitor, signal filter or strategy, or they can be daisy chained to each other while the last indicator in the chain connects to the signal monitor, signal filter or strategy. When using a signal filter you can chain the filter to the strategy input to make your chain complete.

snapshot

 • Direct chaining: Connect an indicator directly to the signal monitor, signal filter or strategy through the provided inputs (→).
 • Daisy chaining: Connect indicators using the indicator input (→). The first in a daisy chain should have a flow (⌥) set to 'Indicator only'. Subsequent indicators use 'Both' to pass the previous weight. The final indicator connects to the signal monitor, signal filter, or strategy.



 ■ Set up the strategy with a signal filter and an RSI indicator

Let's connect the Strategy to a connectable signal filter and a connectable RSI indicator:


1. Load all relevant indicators
 • Load RSI / Connectable
 • Load Signal filter / Connectable
 • Load Strategy / Connectable

2. Signal Filter: Connect the RSI to the Signal Filter
 • Open the signal filter settings
 • Choose one of the three input dropdowns (1→, 2→, 3→) and choose : RSI / Connectable: Signal Connector
 • Toggle the enable box before the connected input to enable the incoming signal

3. Signal Filter: Update the filter signals settings if needed
 • The default settings of the filter enable EL (Enter Long), XL (Exit Long), ES (Enter Short) and XS (Exit Short).

4. Signal Filter: Update the weight threshold settings if needed
 • All connectable indicators load by default with a score of 6 for each direction (EL, XL, ES, XS)
 • By default, weight threshold (TH) is set at 5. This allows each occurrence to score, as the default score in each connectable indicator is 1 point above the threshold. Adjust to your liking.

5. Strategy: Connect the strategy to the signal filter in the strategy settings
 • Select the strategy input → and select the Signal filter: Signal connector

6. Strategy: Enable filter compatible directions
 • Set the signal mode of the strategy to a compatible direction with the signal filter.





Now that everything is connected, you'll notice green spikes in the signal filter representing long signals, and red spikes indicating short signals. Trades will also appear on the chart, complemented by a performance overview. Your journey is just beginning: delve into different scoring mechanisms, merge diverse connectable indicators, and craft unique chains. Instantly test your results and discover the potential of your configurations. Dive deep and enjoy the process!



BENEFITS

 • Adaptable Modular Design: Arrange indicators in diverse structures via direct or daisy chaining, allowing tailored configurations to align with your analysis approach.
 • Streamlined Backtesting: Simplify the iterative process of testing and adjusting combinations, facilitating a smoother exploration of potential setups.
 • Intuitive Interface: Navigate TradingView with added ease. Integrate desired indicators, adjust settings, and establish alerts without delving into complex code.
 • Signal Weight Precision: Leverage granular weight allocation among signals, offering a deeper layer of customization in strategy formulation.
 • Advanced Signal Filtering: Define entry and exit conditions with more clarity, granting an added layer of strategy precision.
 • Clear Visual Feedback: Distinct visual signals and cues enhance the readability of charts, promoting informed decision-making.
 • Standardized Defaults: Indicators are equipped with universally recognized preset settings, ensuring consistency in initial setups across different types like momentum or volatility.
 • Reliability: Our indicators are meticulously developed to prevent repainting. We strictly adhere to TradingView's coding conventions, ensuring our code is both performant and clean.



COMPATIBLE INDICATORS

Each indicator that incorporates our open-source 'azLibConnector' library and adheres to our conventions can be effortlessly integrated and used as detailed above.
For clarity and recognition within the TradingView platform, we append the suffix ' / Connectable' to every compatible indicator.



COMMON MISTAKES AND CLARIFICATIONS

 • Removing an indicator from a chain: Deleting a linked indicator and confirming the "remove study tree" alert will also remove all underlying indicators in the object tree. Before removing one, disconnect the adjacent indicators and move it to the object stack's bottom.
 • Point systems: The azLibConnector provides 500 points for each direction (EL: Enter long, XL: Exit long, ES: Enter short, XS: Exit short) Remember this cap when devising a point structure.
 • Flow misconfiguration: In daisy chains the first indicator should always have a flow (⌥) setting of 'indicator only' while other indicator should have a flow (⌥) setting of 'both'.
 • Recalculate: While this strategy has undergone extensive testing, enabling recalculation options like 'After order is filled' or 'On every tick' may lead to unexpected behavior.
 • Fill orders: The strategy is thoroughly tested, yet enabling fill order options such as 'Using bar magnifier', 'On bar close', or 'Using standard OHLC' might result in unexpected outcomes.
 • Layout and abbreviations: To maintain a consistent structure, we use abbreviations for each input. While this may initially seem complex, you'll quickly become familiar with them. Each abbreviation is also explained in the inline tooltips.
 • Optimized for crypto trading: While many principles are common across markets, this strategy is specifically optimized and tested for crypto trading.
 • Inputs: Connecting a connectable indicator directly to the strategy delivers the raw signal without a weight threshold, meaning every signal will trigger a trade.


A NOTE OF GRATITUDE

Through years of exploring TradingView and Pine Script, we've drawn immense inspiration from the community's knowledge and innovation. Thank you for being a constant source of motivation and insight.



RISK DISCLAIMER

Azullian's content, tools, scripts, articles, and educational offerings are presented purely for educational and informational uses. Please be aware that past performance should not be considered a predictor of future results.



Notes de version
- Updated license
Notes de version
- Update 'azLibConnector' version
connectableconnectablestrategyeducational

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?


🔗 Explore and learn about connectable indicators on Azullian: azullian.com

🔗 Check out how it works: youtu.be/gPNz0XiZl38
🔗 Strategy plus demo: youtu.be/jRpvt_ZdIOg
🔗 Join our discord: discord.com/invite/vT7AqmE
Aussi sur:

Clause de non-responsabilité