INVITE-ONLY SCRIPT
Telah dikemas kini

Democratic MultiAsset Strategy [BerlinCode42]

154
Happy Trade,

  1. Intro
  2. Included Trade Concept
  3. Included Indicators and Compare-Functions
  4. Usage and Example
  5. Settings Menu
  6. Declaration for Tradingview House Rules on Script Publishing
  7. Disclaimer
  8. Conclusion


1. Intro

This is the first multi-asset strategy available on TradingView—a market breadth multi-asset trading strategy with integrated webhooks, backtesting capabilities, and essential strategy components like Take Profit, Stop Loss, Trailing, Hedging, Time & Session Filters, and Alerts.
How It Trades? At the start of each new bar, one asset from a set of eight is selected to go long or short. As long there is available cash and the selected asset meets the minimum criteria.
The selection process works through a voting system, similar to a democracy. Each asset is evaluated using up to five indicators that the user can choose. The asset with the highest overall voting score is picked for the trade. If no asset meets all criteria, no trade is executed, and the cash reserve remains untouched for future opportunities.
How to Set Up This Market Breadth Strategy:
  • Choose eight assets from the same market (e.g., cryptos or big tech stocks).
  • Select one to five indicators for the voting system.
  • Refine the strategy by adjusting Take Profit, Stop Loss, Hedging, Trailing, and Filters.


2. Voting as the included Trade Concept

The world of financial trading is filled with both risks and opportunities, and the key challenge is to identify the right opportunities, manage risks, and do both right on time.
There are countless indicators designed to spot opportunities and filter out risks, but no indicator is perfect—they only work statistically, hitting the right signals more often than the wrong ones.
The goal of this strategy is to increase the accuracy of these Indicators by:
  • Supervising a larger number of assets
  • Filtering out less promising opportunities

This is achieved through a voting system that compares indicator values across eight different assets. It doesn't just compare long trades—it also evaluates long vs. short positions to identify the most promising trade.
Why focus on one asset class? While you can randomly select assets from different asset classes, doing so prevents the algorithm from identifying the strongest asset within a single class. Think about, within one asset class there is often a major trend whereby different asset classes has not really such behavior.
And, you don’t necessarily need trading in multiple classes—this algorithm is designed to generate profits in both bullish and bearish markets. So when ever an asset class rise or fall the voting system ensure to jump on the strongest asset. So this focusing on one asset class is an integral part of this strategy. This all leads to more stable and robust trading results compared to handling each asset separately.

3. Included Indicators and Compare-Functions

You can choose from 17 different indicators, each offering different types of signals:
  • Some provide a directional signal
  • Some offer a simple on/off signal
  • Some provide both


Available Indicators: RSI, Stochastic RSI, MFI, Price, Volume, Volume Oscillator, Pressure, Bilson Gann Trend, Confluence, TDI, SMA, EMA, WMA, HMA, VWAP, ZLMA, T3MA
However, these indicators alone do not generate trade signals. To do so, they must be compared with thresholds or other indicators using specific comparison functions.

Example – RSI as a Trade Signal. The RSI provides a value between 0 and 100. A common interpretation is:
  • RSI over 80 → Signal to go short or exit a long trade
  • RSI under 20 → Signal to go long or exit a short trade

Here, two comparison functions and two thresholds are used to determine trade signals.
Below is the full set of available comparison functions, where: I represents the indicator’s value and A represents the comparator’s value.

  • I < A if I smaller A then trade signal
  • I > A if I bigger A then trade signal
  • I = A if I equal to A then trade signal
  • I != A if I not equal to A then trade signal
  • A <> B if I bigger A and I smaller B then trade signal
  • A >< B if I smaller A then long trade signal or if I bigger B then short trade signal


syot kilat
Image 1

In Image 1, you can see one of five input sections, where you define an indicator along with its function, comparator, and constants. For our RSI example, we select:

  • Indicator: RSI
  • Function: >< (greater/less than)
  • Comparator: Constant
  • Constants: A = 20, B = 80


With these settings a go short signal is triggered when RSI crosses above 80. And a go long signal is triggered when RSI crosses below 20.

  • Relative Strength Indicator: The RSI from the public TradingView library provides a directional trade signal. You can adjust the price source and period length in the indicator settings.

  • Stochastic Relative Strength Indicator: As above the Stoch RSI offers a trade signal with direction. It is calculated out of the RSI, the stochastic derivation and the SMA from the Tradingview library. You can set the in-going price source and the period length for the RSI, for the Stochastic Derivation and for the SMA as blurring in the Indicator settings section.

  • Money Flow Indicator: As above the MFI from the public Tradingview library offers a trade signal with direction. You can set the in-going price source and the period length in the Indicator settings section.

  • Price: The Price as Indicator is as simple as it can be. You can chose Open, High, Low or Close or combinations of them like HLC3 or even you can import an external Indicator. The absolute price or value can later be used to generate a trade signals when certain constant thresholds or other indicators signals are crossed.

  • Volume: Similar as above the Volume as Indicator offers the average volume as absolute value. You can set the period length for the smoothing and you can chose where it is presented in the base currency $ or is the other. For example the trade pair BTCUSD you can chose to present the value in $ or in BTC.

  • Volume Oscillator: The Volume Oscillator Indicator offers a value in the range of [0..2]. Whereby a value close to 0 means that the volume is very low. A value around 1 means the volume is same high as before and Values higher as 1 means the volume is bigger then before. You can set the period length for the smoothing and you can chose where it is presented in the base currency $ or is the other. For example the trade pair BTCUSD you can chose to present the value in $ or in BTC.

  • Pressure Indicator: The Pressure is an adapted version of LazyBear's script (Squeeze Momentum Indicator) tradingview.com/script/nqQ1DT5a-Squeeze-Momentum-Indicator-LazyBear/. Pressure is a Filter that highlight bars before a bigger price move in any direction. The result are integer numbers between 0 and 4 whereby 0 means no bigger price move excepted, while 4 means huge price move expected. You can set the in-going price source and the period length in the Indicator settings section.

  • Bilson Gann Trend: The Bilson Gann Trend Indicator is a specific re-implementation of the widely known Bilson Gann Count Algorithm to detect Highs and Lows. On base of the last four Highs and Lows a trend direction can be calculated. It is based on 2 rules to confirm a local pivot candidate. When a local pivot candidate is confirmed, let it be a High then it looks for Lows to confirm. The result range is [-1,0,1] whereby -1 means down trend, 1 means uptrend and 0 sideways.

  • Confluence: The Confluence Indicator is a simplified version of Dale Legan's "Confluence" indicator written by Gary Fritz. It uses five SMAs with different periods lengths. Whereby the faster SMA get compared with the (slower) SMA with the next higher period lengths. Is the faster SMA smaller then the slower SMA then -1, otherwise +1. This is done with all SMAs and the final sum range between [-4,-2,0,2,4]. Whereby values around 0 means price is going side way, Crossing under 0 means trend change from bull to bear. Is the value>2 means a strong bull trend and <-2 a strong bear trend.

  • Trades Dynamic Index: The TDI is an adapted version from the "Traders Dynamic Index" of LazyBear. The range of the result is [-2,-1,0,1,2] whereby 2 means Top goShort, -2 means Bottom goLong, 0 is neutral, 1 is up trend, -1 is down trend.

  • Simple Moving Average: The SMA is the one from the Tradingview library. You can compare it with the last close price or any other moving average indicator to indicate up and down trends. You can set the in-going price source and the period length in the Indicator settings section.

  • Exponential Moving Average: The EMA as above is the one from the Tradingview library. You can compare it with the last close price or any other moving average indicator to indicate up and down trends. You can set the in-going price source and the period length in the Indicator settings section.

  • Weighted Moving Average: The WMA as above is the one from the Tradingview library. You can compare it with the last close price or any other moving average indicator to indicate up and down trends. You can set the in-going price source and the period length in the Indicator settings section.

  • Hull Moving Average: HMA as above is the one from the Tradingview library. You can compare it with the last close price or any other moving average indicator to indicate up and down trends. You can set the in-going price source and the period length in the Indicator settings section.

  • Volume Weighted Average Price: The VWAP as above is the one from the Tradingview library. You can compare it with the last close price or any other moving average indicator to indicate up and down trends. You can set the in-going price source in the Indicator settings section.

  • Zero Lag Moving Average: The ZLMA by John Ehlers and Ric Way describe in their paper: mesasoftware.com/papers/ZeroLag.pdf
    As the other moving averages you can compare it with the last close price or any other moving average indicator to indicate up and down trends. You can set the in-going price source and the period length in the Indicator settings section.

  • T3 Moving Average: The T3MA is the one from the Tradingview library. You can compare it with the last close price or any other moving average indicator to indicate up and down trends. You can set the in-going price source, the period length and a factor in the Indicator settings section. Keep this factor at 1 and the T3MA swing in the same range as the input. Bigger 1 and it swings over. Factors close to 0 and the T3MA becomes a center line.


All MA's following the price. The function to compare any MA Indicators would be < or > to generate a trade direction. An example follows in the next section.

4. Example and Usage

In this section, you see how to set up the strategy using a simple example. This example was intentionally chosen at random and has not undergone any iterations to refine the trade results.

We use the RSI as the trade signal indicator and apply a filter using a combination of two moving averages (MAs). The faster MA is an EMA, while the slower MA is an SMA. By comparing these two MAs, we determine a trend direction. If the faster MA is above the slower MA the trend is upwards etc. This trend direction can then be used for filtering trades.

The strategy follows these rules:
  • If the RSI is below 20, a buy signal is generated.
  • If the RSI is above 80, a sell signal is generated.


However, this RSI trade signal is filtered so that a trade is only given the maximum voting weight if the RSI trade direction aligns with the trend direction determined by the MA filter.
So first, you need to add your chosen assets or simply keep the default ones. In Image 2, you can see one of the eight asset input sections.

syot kilat
Image 2

This strategy offers some general trade settings that apply equally to all assets and some asset-specific settings. This distinction is necessary because some assets have higher volatility than others, requiring asset-specific Take Profit and Stop Loss levels.
Once you have made your selections, proceed to the Indicators and Compare Functions for the voting. Image 3 shows an example of this setup.

syot kilat
Image 3

Later on go to the Indicator specific settings shown in Image 4 to refine the trade results.

syot kilat
Image 4

For refine the trade results take also a look on the result summary table, development of capital plot, on the list of closed and open trades and screener table shown in Image 5.

syot kilat
Image 5

To locate any trade for any asset in the chronological and scroll-able trade list, each trade is marked with a label:

  • An opening label displaying the trade direction, ticker ID, trade number, invested amount, and remaining cash reserves.
  • A closing label showing the closing reason, ticker ID, trade number, trade profit (%), trade revenue ($), and updated cash reserves.


Additionally: a green line marks each Take Profit level. An orange line indicates the (trailing) Stop Loss.
The summary table in the bottom-left corner provides insights into how effective the trade strategy is. By analyzing the trade list, you can identify trades that should be avoided.
To find those bad trades on the chart, use the trade number or timestamp. With replay mode, you can go back in time to review a specific trade in detail.

syot kilat
Image 6

In Image 6, you can see an example where replay mode and the start time filter are used to display specific trades within a narrow time range. By identifying a large number of bad trades, you may recognize patterns and formulate conditions to avoid them in the future.
This is the backtesting tool that allows you to develop and refine your trading strategy continuously. With each iteration—from general adjustments to detailed optimizations—you can use these tools to improve your strategy. You can:

  • Add other indicators with trade signals and direction
  • Add more indicators signals as filter
  • Adjust the settings of your indicators to optimize results
  • Configure key strategy settings, such as Time and Session Filters, Stop Loss, Take Profit, and more


By doing so, you can identify a profitable strategy and its optimal settings.

5. Settings Menu

In the settings menu you will find the following high-lighted sections. Most of the settings have a i mark on their right side. Move over it with the cursor to read specific explanation.

Backtest Results: Here you can decide about visibility of the trade list, of the Screener Table and of the Results Summary. And the colors for bullish, side ways, bearish and no signal. Go above and see Image 5.

Time Filter: You can set a Start time or deactivate it by leave it unhooked. The same with End Time and Duration Days. Duration Days can also count from End time in case you deactivate Start time.

Session Filter: Here, you can chose to activate trading on a weekly basis, specifying which days of the week trading is allowed and which are excluded. Additionally, you can configure trading on a daily basis, setting the start and end times for when trades are permitted. If activated, no new trades will be initiated outside the defined times and sessions.

Trade Logic: Here you can set an extra time frame for all indicators. You can enable Longs or Shorts or both trades.
The min Criteria percentage setting defines the minimum number of voices an asset has to get to be traded. So if you set this to 50% or less also weak winners of the voting get traded while 100% means that the winner of the voting has to get all possible voices.
Additionally, you have the option to delay entry signals. This feature is particularly useful when trade signals exhibit noise and require smoothing.
Enable Trailing Stop and force the strategy to trade only at bar closing. Other-ways the strategy trade intrabar, so when ever a voting present an asset to trade, it will send the alert and the webhooks.
The Hedging is basic as shown in the following Image 7 and serves as a catch if price moves fast in the wrong direction. You can activate a hedging mechanism, which opens a trade in the opposite direction if the price moves x% against the entry price. If both the Stop Loss and Hedging are triggered within the same bar, the hedging action will always take precedence.


syot kilat
Image 6

Indicators to use for Trade Signal Generating: Here you chose the Indicators and their Compare Function for the Voting. Any activated asset will get their indicator valuation which get compared over all assets. The asset with the highest valuation is elected for the trade as long free cash is present and as long the minimum criteria are met.
The Screener Table will show all indicators results of the last bar of all assets. Those indicator values which met the threshold get a background color to high light it. Green for bullish, red for bearish and orange for trade signals without direction. If you chose an Indicator here but without any compare function it will show also their results but with just gray background.

Indicator Settings: here you can setup the indicator specific settings. for deeper insights see 3. Included Indicators and Compare-Functions.

Assets, TP & SL Settings: Asset specific settings. Chose here the TickerID of all Assets you wanna trade. Take Profit 1&2 set the target prices of any trade in relation to the entry price. The Take Profit 1 exit a part of the position defined by the quantity value. Stop Loss set the price to step out when a trade goes the wrong direction.

Invest Settings: Here, you can set the initial amount of cash to start with. The Quantity Percentage determines how much of the available cash is allocated to each trade, while the Fee percentage specifies the trading fee applied to both opening and closing positions.

Webhooks: Here, you configure the License ID and the Comment. This is particularly useful if you plan to use multiple instances of the script, ensuring the webhooks target the correct positions. The Take Profit and Stop Loss values are displayed as prices.


syot kilat

6. Declaration for Tradingview House Rules on Script Publishing

The unique feature of this Democratic Multi-Asset Strategy is its ability to trade multiple assets simultaneously. Equipped with a set of different standard Indicators, it's new democratic Voting System does more robust trading decisions compared to single-asset. Interchangeable Indicators and customizable strategy settings allowing for a wide range of trading strategies.

This script is closed-source and invite-only to support and compensate for over a year of development work. Unlike other single asset strategies, this one cannot use TradingView's strategy functions. Instead, it is designed as an indicator.

7. Disclaimer

Trading is risky, and traders do lose money, eventually all. This script is for informational and educational purposes only. All content should be considered hypothetical, selected post-factum and is not to be construed as financial advice. Decisions to buy, sell, hold, or trade in securities, commodities, and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results. Using this script on your own risk. This script may have bugs and I declare don't be responsible for any losses.

8. Conclusion

Now it’s your turn! Chose an asset class and pick 8 of them and chose some indicators to see the trading results of this democratic voting system. Refine your multi-asset strategy to favorable settings. Once you find a promising configuration, you can set up alerts to send webhooks directly. Configure all parameters, test and validate them in paper trading, and if results align with your expectations, you even can deploy this script as your trading bit.

Cheers
Nota Keluaran
Adding the new "Cutting" function:
When activated, this function exits the most unprofitable trade if the cash reserve drops below 5% of the starting capital and new trade signals appear.

This feature helps to reduce risk in a strategies without relying on stop loss orders.

Debugging Fee:
Fixed an issue with fee calculation.

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.