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

AlphaTrend Dual Tracking Strategy

Author: ChaoZhang, Date: 2024-02-02 15:17:01
Tags:

img

Overview

The AlphaTrend dual tracking strategy trades based on the buy and sell signals generated by the AlphaTrend indicator. It opens long and short positions in the areas where AlphaTrend produces buy and sell signals.

Strategy Logic

The core of the AlphaTrend dual tracking strategy is the AlphaTrend indicator. The AlphaTrend indicator calculates the upper and lower bands based on the adaptive ATR and price (close price or volume weighted average price). The specific calculation method is:

Upper Band = Lowest Low - ATR * Multiplier Lower Band = Highest High + ATR * Multiplier

Where ATR is the average true range over a certain period and multiplier is an adjustable parameter. When price is above the upper band, the indicator line approaches the upper band. When price is below the lower band, the indicator line approaches the lower band. Thus AlphaTrend forms an adaptive channel.

The AlphaTrend dual tracking strategy establishes long and short positions based on the signals generated by AlphaTrend. The specific logic is:

  • Go long when price crosses above AlphaTrend;
  • Go short when price crosses below AlphaTrend.

This completes the dual-directional tracking trading based on the dynamic AlphaTrend channel.

Advantage Analysis

The biggest advantage of AlphaTrend dual tracking strategy is that it can track changes in market trends. The adaptive ATR can adjust the channel range according to changes in market volatility, avoiding the problem of traditional Bollinger Bands losing effectiveness due to volatility expansion.

In addition, AlphaTrend combines both price and volume (or momentum) information, which helps filter out some false breakouts, improving the quality of trading signals.

Risk Analysis

The main risk of the AlphaTrend dual tracking strategy comes from huge market fluctuations that could hit the stop loss points. When there is abnormal market movement, the stop loss points may be broken, leading to large losses. This needs to be controlled by properly adjusting ATR parameters and stop loss points.

In addition, ALPHA itself has some lagging. It may also generate incorrect signals around market turning points. Other indicators should be used to confirm the signals.

Optimization Directions

The AlphaTrend dual tracking strategy can be optimized in the following aspects:

  1. Combine with trend indicators to determine the major market trend to avoid trading against the trend;
  2. Increase volume filter to avoid losses caused by low volume false breakouts;
  3. Optimize indicator parameters to make the channel range more suitable for different products;
  4. Increase machine learning algorithms to make the channel more intelligent.

Through the above optimizations, the stability and profitability of the AlphaTrend strategy can be further improved.

Summary

In summary, the AlphaTrend dual tracking strategy is an effective way to track market changes. It solves the problem of traditional technical indicators losing effectiveness and also incorporates volume information to filter signals. With proper optimizations, this strategy can become a powerful tool in quantitative trading systems.


/*backtest
start: 2024-01-02 00:00:00
end: 2024-02-01 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// author © KivancOzbilgic
// developer © KivancOzbilgic
//@version=5
strategy('AlphaTrend', shorttitle='AT', overlay=true, format=format.price, precision=2)
coeff = input.float(1, 'Multiplier', step=0.1)
AP = input(14, 'Common Period')
ATR = ta.sma(ta.tr, AP)
src = input(close)
showsignalsk = input(title='Show Signals?', defval=true)
novolumedata = input(title='Change calculation (no volume data)?', defval=false)
upT = low - ATR * coeff
downT = high + ATR * coeff
AlphaTrend = 0.0
AlphaTrend := (novolumedata ? ta.rsi(src, AP) >= 50 : ta.mfi(hlc3, AP) >= 50) ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT

color1 = AlphaTrend > AlphaTrend[2] ? #00E60F : AlphaTrend < AlphaTrend[2] ? #80000B : AlphaTrend[1] > AlphaTrend[3] ? #00E60F : #80000B
k1 = plot(AlphaTrend, color=color.new(#0022FC, 0), linewidth=3)
k2 = plot(AlphaTrend[2], color=color.new(#FC0400, 0), linewidth=3)

fill(k1, k2, color=color1)

buySignalk = ta.crossover(AlphaTrend, AlphaTrend[2])
sellSignalk = ta.crossunder(AlphaTrend, AlphaTrend[2])


K1 = ta.barssince(buySignalk)
K2 = ta.barssince(sellSignalk)
O1 = ta.barssince(buySignalk[1])
O2 = ta.barssince(sellSignalk[1])

//plotshape(buySignalk and showsignalsk and O1 > K2 ? AlphaTrend[2] * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0022FC, 0), textcolor=color.new(color.white, 0))

//plotshape(sellSignalk and showsignalsk and O2 > K1 ? AlphaTrend[2] * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.maroon, 0), textcolor=color.new(color.white, 0))



longCondition = buySignalk and showsignalsk and O1 > K2
if (longCondition)
    
    strategy.entry("BUY", strategy.long, comment = "BUY ENTRY")

shortCondition = sellSignalk and showsignalsk and O2 > K1
if (shortCondition )
    
    strategy.entry("SELL", strategy.short, comment = "SELL ENTRY")













// alertcondition(buySignalk and O1 > K2, title='Potential BUY Alarm', message='BUY SIGNAL!')
// alertcondition(sellSignalk and O2 > K1, title='Potential SELL Alarm', message='SELL SIGNAL!')

// alertcondition(buySignalk[1] and O1[1] > K2, title='Confirmed BUY Alarm', message='BUY SIGNAL APPROVED!')
// alertcondition(sellSignalk[1] and O2[1] > K1, title='Confirmed SELL Alarm', message='SELL SIGNAL APPROVED!')



// alertcondition(ta.cross(close, AlphaTrend), title='Price Cross Alert', message='Price - AlphaTrend Crossing!')
// alertcondition(ta.crossover(low, AlphaTrend), title='Candle CrossOver Alarm', message='LAST BAR is ABOVE ALPHATREND')
// alertcondition(ta.crossunder(high, AlphaTrend), title='Candle CrossUnder Alarm', message='LAST BAR is BELOW ALPHATREND!')

// alertcondition(ta.cross(close[1], AlphaTrend[1]), title='Price Cross Alert After Bar Close', message='Price - AlphaTrend Crossing!')
// alertcondition(ta.crossover(low[1], AlphaTrend[1]), title='Candle CrossOver Alarm After Bar Close', message='LAST BAR is ABOVE ALPHATREND!')
// alertcondition(ta.crossunder(high[1], AlphaTrend[1]), title='Candle CrossUnder Alarm After Bar Close', message='LAST BAR is BELOW ALPHATREND!')






More