OPEN-SOURCE SCRIPT

Optimized Weighted Buy-Sell Strategy

Optimized Weighted Buy-Sell Strategy

Overview

The Optimized Weighted Buy-Sell Strategy is a comprehensive algorithm designed to identify high-confidence trading opportunities by combining seven powerful technical indicators. The strategy ensures that buy and sell trades alternate to avoid multiple consecutive trades in the same direction, providing traders with more reliable signals.

This strategy works across multiple market conditions and timeframes, offering flexibility for trend-following or mean-reversion strategies. It is fully customizable, allowing traders to adjust indicator settings and thresholds to suit their trading style.

Key Features

Weighted Multi-Indicator System: Incorporates seven indicators to filter out noise and generate reliable buy/sell signals.
Prevents Consecutive Entries: Ensures buy and sell trades alternate by tracking position size.
Highly Customizable: All indicator settings and thresholds can be adjusted by the user.
Works on All Timeframes: Use it for scalping, swing trading, or long-term trend-following.
Visual Buy/Sell Cues: Signals are plotted directly on the price chart for easy interpretation.

How It Works

The strategy calculates weighted scores based on the alignment of multiple indicators. Each indicator is assigned a specific weight, and when the combined score reaches or exceeds the threshold (7 points), a buy or sell signal is generated.

Buy Signal: Generated when bullish conditions align, and the strategy is not already in a long position.

Sell Signal: Triggered when bearish conditions are met, and the strategy already holds a long position.

The strategy avoids multiple entries in the same direction by ensuring that buy and sell trades alternate.

Indicators and Weightage Breakdown

Here is a breakdown of the indicators, the conditions they evaluate, and their respective weights:

1. Exponential Moving Average (EMA):

Buy: Short EMA > Long EMA
Weight: 3 points
Sell: Short EMA < Long EMA
Weight: 3 points

2. Relative Strength Index (RSI):

Buy: RSI < 35, followed by a crossover above 40
Weight: 2 points
Sell: RSI > 65, followed by a crossunder below 60
Weight: 2 points

3. MACD (Moving Average Convergence Divergence):

Buy: MACD Line > Signal Line (bullish crossover)
Weight: 2 points
Sell: MACD Line < Signal Line (bearish crossover)
Weight: 2 points

4. Stochastic Oscillator:

Buy: K Line > D Line, with K < 30
Weight: 1 point
Sell: K Line < D Line, with K > 70
Weight: 1 point

5. Bollinger Bands:

Buy: Close > Lower Bollinger Band
Weight: 1 point
Sell: Close < Upper Bollinger Band
Weight: 1 point

6. On-Balance Volume (OBV):

Buy: OBV increases compared to the previous bar
Weight: 1 point
Sell: OBV decreases compared to the previous bar
Weight: 1 point

7. Average Directional Index (ADX):

Buy: ADX > 15 and plusDI > minusDI
Weight: 2 points
Sell: ADX < 15 or minusDI > plusDI
Weight: 2 points

Customization Options

This strategy allows users to adjust key parameters to match their trading preferences. Some of the customizable settings include:

EMA Periods: Control the short and long EMA periods for trend detection.
RSI and Stochastic Settings: Fine-tune momentum oscillators for your preferred timeframe.
MACD and ADX Settings: Adjust for stronger or weaker trend conditions.
Threshold for Signals: Change the threshold to increase or reduce sensitivity to buy/sell signals.

Example Use Case

Swing Trading: Use this strategy on a 4-hour timeframe to catch trend reversals with high confidence.
Scalping: Apply it on a 5-minute chart with tighter thresholds for rapid market movements.
Long-Term Investing: Monitor major trend shifts on daily or weekly charts by adjusting indicator parameters.

Conclusion

The Optimized Weighted Buy-Sell Strategy offers a robust, rules-based approach to trading by leveraging the power of multiple indicators. With visual buy/sell cues and customization options, this strategy is suitable for traders of all levels, from beginners to advanced users.

However, as with all trading strategies, users are encouraged to backtest thoroughly and fine-tune the parameters to match their market and trading style.

Backtesting Results

Example backtesting results for BTCUSD (CRYPTO) on 1 hour timeframe (3 Januray 2024 to 18 October 2024):

Total closed trades = 40
Net profit = 28,913 USD
Percent profitable = 47.50%
ADXbollingersbandExponential Moving Average (EMA)exponentialmovingaveragesmacdivergencerelative-strength-indexRelative Strength Index (RSI)Stochastic Oscillatorstochasticoscillator

Skrypt open-source

W prawdziwym duchu TradingView autor tego skryptu opublikował go jako open source, aby inwestorzy mogli go zrozumieć i zweryfikować. Pozdrowienia dla autora! Możesz go używać bezpłatnie, ale ponowne użycie tego kodu w publikacji podlega Zasadom Regulaminu. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Chcesz użyć tego skryptu na wykresie?


Również na:

Wyłączenie odpowiedzialności