资源加载中... loading...

Multi-Indicator Quantitative Trading Strategy - Super Indicator 7-in-1 Strategy

Author: ChaoZhang, Date: 2024-05-23 18:20:25
Tags: SMAEMARSIMACD

img

Overview

The “Super Indicator 7-in-1 Strategy” is a quantitative trading strategy that integrates seven popular technical indicators, including the Relative Strength Index (RSI), Moving Average Convergence Divergence (MACD), Stochastic Oscillator, Bollinger Bands, Simple Moving Average (SMA), Exponential Moving Average (EMA), and Volume. By combining the signals from these indicators, the strategy aims to identify overbought and oversold market conditions and pinpoint optimal buying and selling opportunities. The strategy also incorporates take profit, stop loss, and time-based filters to optimize trade execution and risk management.

Strategy Principles

The core principle of this strategy is to leverage multiple technical indicators to obtain more comprehensive and reliable trading signals. Each indicator has its unique calculation method and perspective on interpreting market trends. For example, RSI measures the speed and strength of price movements; MACD determines trends based on moving average crossovers; the Stochastic Oscillator assesses overbought and oversold levels by comparing the closing price to the price range over a certain period; and Bollinger Bands set upper and lower bounds based on price volatility.

The strategy generates buy and sell signals by setting thresholds and evaluating the combined strength of multiple indicator signals. When indicators reach certain combinations of conditions, it triggers a trading signal. The strategy also considers other market information, such as volume, to confirm price movements. Additionally, the strategy incorporates risk management and optimization measures, including take profit, stop loss, and trading session filters, to seize opportunities while controlling risks.

Advantage Analysis

The main advantages of the “Super Indicator 7-in-1 Strategy” lie in its comprehensiveness and flexibility. By considering multiple indicators, the strategy can validate market signals from different angles, increasing the probability of generating reliable trading opportunities. Even if individual indicators produce misleading signals, as long as most indicators align, the strategy can still make correct judgments.

Moreover, the strategy offers a wide range of parameter options, allowing users to customize settings according to their preferences and trading styles. Different parameter combinations can generate signals with varying sensitivity and frequency, adapting to different market conditions. The strategy also includes built-in risk management tools, such as take profit, stop loss, and trading session filters, further enhancing its practicality and controllability.

Risk Analysis

Despite its numerous advantages, the strategy also has some potential risks. First, the strategy’s performance heavily depends on the reasonableness of the selected parameters. Inappropriate parameter settings can lead to signal distortions and incorrect trading decisions. Second, the strategy primarily relies on historical data and statistical patterns, while market conditions are ever-changing, and past patterns may not apply to the future.

Furthermore, under extreme market conditions, multiple indicators may simultaneously fail, causing the strategy to make erroneous judgments. The strategy may also generate conflicting signals in choppy markets, resulting in overtrading and rapid capital depletion.

Optimization Directions

To further enhance the strategy’s robustness and profit potential, consider the following optimization aspects:

  1. Conduct more systematic backtesting and optimization of indicator parameters to identify the optimal combination.
  2. Introduce additional non-price indicators, such as sentiment and fundamental indicators, to broaden the strategy’s perspective.
  3. Refine the take profit and stop loss logic by setting dynamic percentages or employing trailing stops.
  4. Incorporate considerations for specific events (e.g., significant economic data releases) into the trading session filter.
  5. Perform secondary confirmation of the signals generated by the strategy, such as evaluating indicator performance across multiple timeframes.

Through these optimizations, the strategy can maintain its advantages while further enhancing its ability to navigate complex market environments, delivering more consistent returns for users.

Summary

In summary, the “Super Indicator 7-in-1 Strategy” is a powerful and well-designed quantitative trading strategy. It cleverly combines seven commonly used technical indicators to grasp market dynamics from multiple angles and provide traders with reliable buy and sell signals. The rich parameter options and built-in risk management tools make the strategy flexible, user-friendly, and adaptable.

However, the strategy’s performance is still influenced by factors such as parameter selection and market conditions. Traders need to fine-tune the strategy based on their own experience and backtesting results. By introducing more indicator dimensions, optimizing take profit and stop loss logic, and refining trading session filters, the strategy can further enhance its risk resilience and profit potential, becoming a valuable tool for quantitative traders.


/*backtest
start: 2024-04-22 00:00:00
end: 2024-05-22 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title='Super Indicator 7 in 1', shorttitle='Super Indicator 7 in 1', overlay=true, initial_capital=100, pyramiding=0, default_qty_value=10000, default_qty_type=strategy.cash)

// Defining indicator parameters
show_plots = input(false, title="Show Plots", group="Visibility")
show_indicators = input(false, title="Show Indicators", group="Visibility")
show_trades = input(true, title="Show Trades", group="Visibility")
show_labels = input(false, title="Show Labels", group="Visibility")
start_hour = input.int(0, title="Start Hour (24h format)", group="Time-Based Filter", minval=0, maxval=24)
end_hour = input.int(24, title="End Hour (24h format)", group="Time-Based Filter", minval=0, maxval=24)
stop_trading = input(false, "Stop Trading", group="Time-Based Filter")
trade_time = (hour >= start_hour and hour <= end_hour)
bgcolor(trade_time and (start_hour != 0 or end_hour != 24) ? color.new(color.blue, 90) : na)

volume_length = input.int(1, title="Volume SMA Length", group="Volume", minval=1, step=1)
sma_period = input.int(50, title="SMA Period", group="Moving Averages")
ema_period = input.int(50, title="EMA Period", group="Moving Averages")
bb_length = input.int(20, title='Bollinger Bands Length', group="Bollinger Bands")
mult = input.float(2.0, title='Bollinger Bands MultFactor', group="Bollinger Bands")
src = input(close, title='Bollinger Bands Source', group="Bollinger Bands")
rsi_length = input.int(14, title='RSI Length', group="RSI")
macd_fast_length = input.int(12, title='MACD Fast Length', group="MACD")
macd_slow_length = input.int(26, title='MACD Slow Length', group="MACD")
macd_signal_length = input.int(9, title='MACD Signal Smoothing', group="MACD")
stoch_length = input.int(14, title='Stochastic Length', group="Stochastic")
smoothK = input.int(3, title='Stochastic %K Smoothing', group="Stochastic")
smoothD = input.int(3, title='Stochastic %D Smoothing', group="Stochastic")
tp_percent = input.float(0.14, title="Take Profit (%)", group="Trade Settings", minval=0.01, step=0.01) / 100
sl_percent = input.float(0.25, title="Stop Loss (%)", group="Trade Settings", minval=0.01, step=0.01) / 100

// Calculating indicators
dev = mult * ta.stdev(src, bb_length)
upper = ta.sma(src, bb_length) + dev
lower = ta.sma(src, bb_length) - dev
rsi_value = ta.rsi(close, rsi_length)
stoch_value = ta.stoch(close, high, low, stoch_length)
[macd_line, signal_line, _] = ta.macd(close, macd_fast_length, macd_slow_length, macd_signal_length)
k = ta.sma(stoch_value, smoothK)
d = ta.sma(k, smoothD)
sma = ta.sma(close, sma_period)
ema = ta.ema(close, ema_period)
volume_ma = ta.sma(volume, volume_length)
volume_condition = volume >= volume_ma

// Signal definitions(-10%, Normal, +10% and ! failed indicator)
min_buy_signal = rsi_value < 33 and rsi_value > 30 and stoch_value < 22 and stoch_value > 20 and low < lower and macd_line < 0 and volume_condition
min_sell_signal = rsi_value > 63 and rsi_value < 70 and stoch_value > 72 and stoch_value < 80 and high > upper and macd_line > 0 and volume_condition
buy_signal = rsi_value < 30 and stoch_value < 20 and low < lower and macd_line < 0 and volume_condition
sell_signal = rsi_value > 70 and stoch_value > 80 and high > upper and macd_line > 0 and volume_condition
max_buy_signal = rsi_value < 27 and stoch_value < 18 and low < lower and macd_line < 0 and volume_condition
max_sell_signal = rsi_value > 77 and stoch_value > 80 and high > upper and macd_line > 0 and volume_condition
buy_condition = (rsi_value < 30 ? 1 : 0) + (stoch_value < 20 ? 1 : 0) + (macd_line < 0 ? 1 : 0) + (low < lower ? 1 : 0) + (volume_condition ? 1 : 0) == 4
sell_condition = (rsi_value > 70 ? 1 : 0) + (stoch_value > 80 ? 1 : 0) + (macd_line > 0 ? 1 : 0) + (high > upper ? 1 : 0) + (volume_condition ? 1 : 0) == 4

// Plotting buy and sell signals
plotshape(show_plots and min_buy_signal, style=shape.triangleup, location=location.belowbar, color=#00ffb7, size=size.small, title="Min Buy Signal")
plotshape(show_plots and min_sell_signal, style=shape.triangledown, location=location.abovebar, color=#efa803, size=size.small, title="Min Sell Signal")
plotshape(show_plots and buy_signal and not max_buy_signal, style=shape.triangleup, location=location.belowbar, color=#004cff, size=size.small, title="Buy Signal")
plotshape(show_plots and sell_signal and not max_sell_signal, style=shape.triangledown, location=location.abovebar, color=#ffff00, size=size.small, title="Sell Signal")
plotshape(show_plots and max_buy_signal, style=shape.triangleup, location=location.belowbar, color=#1eff00, size=size.small, title="Max Buy Signal")
plotshape(show_plots and max_sell_signal, style=shape.triangledown, location=location.abovebar, color=#ff0000, size=size.small, title="Max Sell Signal")
plotshape(show_plots and buy_condition and not min_buy_signal and not buy_signal and not max_buy_signal, style=shape.triangleup, location=location.belowbar, color=#ffffff, size=size.small, title="Buy Condition")
plotshape(show_plots and sell_condition and not min_sell_signal and not sell_signal and not max_sell_signal, style=shape.triangledown, location=location.abovebar, color=#ffffff, size=size.small, title="Sell Condition")

// Plotting moving averages
plot(show_indicators ? sma : na, color=#fc0000, linewidth=2, title="SMA")
plot(show_indicators ? ema : na, color=#00aaff, linewidth=2, title="EMA")

// Crossover labels for moving averages
BullCross = ta.crossover(ema, sma)
BearCross = ta.crossunder(ema, sma)

if (show_labels)
    if (BullCross)
        label.new(bar_index, sma, color=color.green, textcolor=color.white, style=label.style_cross, size=size.huge)
    if (BearCross)
        label.new(bar_index, sma, color=color.red, textcolor=color.white, style=label.style_cross, size=size.huge)

// Calculating take profit and stop loss
long_take_profit = close * (1 + tp_percent)
long_stop_loss = close * (1 - sl_percent)
short_take_profit = close * (1 - tp_percent)
short_stop_loss = close * (1 + sl_percent)

// Opening long and short orders based on signals
if (show_trades and trade_time and not stop_trading)
    if (min_buy_signal or buy_signal or max_buy_signal or buy_condition)
        strategy.entry("Open Long", strategy.long)
        strategy.exit("TP/SL Long", limit=long_take_profit, stop=long_stop_loss)
    if (min_sell_signal or sell_signal or max_sell_signal or sell_condition)
        strategy.entry("Open Short", strategy.short)
        strategy.exit("TP/SL Short", limit=short_take_profit, stop=short_stop_loss)

template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6