Dual Moving Average Turning Point Strategy

Author: ChaoZhang, Date: 2023-10-24 12:19:04
Tags:

img

See also:

The binary inverse-point trading strategy is a trading strategy based on the inverse-line crossing. It uses two moving averages with different parameter settings to determine the timing of entry and exit based on their inversion. The strategy is simple, intuitive, and easy to implement for medium-long-line trading.

The Principles of Strategy

The strategy uses price as the price input to calculate the mean of two different parameters, SMA1 and SMA2 respectively. The strategy uses the ROC indicator to determine the trend of the mean. When the ROC value of SMA1 exceeds the set positive threshold, the SMA1 is assumed to move up and records the upward signal of the SMA1; when the ROC value of SMA1 breaks the set negative threshold, the SMA1 is assumed to move down and records the downward signal of the SMA1.

When the SMA1 turns up and the upper K-line SMA2 turns down, a buy signal is generated, making more; when the SMA1 turns down and the upper K-line SMA2 turns up, a sell signal is generated, making more.

The strategy uses two inversions of the equator to determine the direction of the trade, one inversion of the equator to confirm the time of entry, and the double inversion of the equator to ensure that the trend changes at the time of entry, effectively filtering out false breakouts.

Analysis of the strengths

  • The use of double-slit cross and turn judgments can effectively filter out false breakouts and improve the accuracy of entry.

  • The combination of the ROC indicator with the uniform turnaround allows a clear determination of the turnaround time and avoids frequent trading.

  • Using the medium-long double-equal line, you can track the main trend and get a bigger trend profit.

  • The strategy logic is simple, clear, easy to understand and is suitable for beginners of quantitative trading.

  • Customization of parameters, adaptation to different market environments, with strong adaptability.

The risk analysis

  • The crossover between the two equator lines can produce a large number of false signals in a volatile market, leading to losses.

  • ROC parameters need to be precisely optimized, otherwise there will be errors in the redirection recognition, which will affect the performance of the strategy.

  • Large cyclical shocks can trigger multiple stop losses, which can be avoided by scaling up the stop losses.

  • Based only on the homogeneous indicators, it is difficult to respond to emergencies such as major news events, which can lead to losses.

  • It is important to note that the parameters are optimized for the fit problem, and the test cycle should be long enough to include different sectors.

Optimized directions

  • Optimize the moving average parameters to find the best combinations of averages

  • Optimized ROC parameters to improve the accuracy of directional recognition

  • Added stop-loss mechanism, allowing for dynamic stops that break through custom price levels

  • Adding additional conditions, such as triggering volume indicators, to avoid false breakouts

  • In combination with other indicators, such as MACD, BOLL, etc.

  • Automatic optimization of parameters to adapt to market changes using methods such as machine learning

Summary

The binary convergence strategy is generally a simple and practical trend tracking strategy. It requires only basic binary indicators, is logically clear and easy to understand, and is very suitable for quantitative trading beginners to learn and practice. Strategy stability can be greatly improved through parameter optimization and stop-loss mechanism optimization.

Overview

The Dual Moving Average Turning Point strategy is a trend following strategy based on moving average crossovers. It uses two moving averages with different parameter settings and determines entry and exit points according to their turning directions. This strategy is simple and intuitive, easy to implement, and suitable for medium-to-long term trading.

Strategy Logic

The strategy uses Price as the price input source and calculates two moving averages, SMA1 and SMA2, with different parameters. It uses the ROC indicator to determine the turning directions of the moving averages. When SMA1’s ROC value exceeds the positive threshold, it is considered an upward turn of SMA1 and an upward signal is recorded. When SMA1’s ROC value breaks the negative threshold, it is considered a downward turn of SMA1 and a downward signal is recorded. The judgment logic for SMA2 is similar.

When SMA1 turns upward and the previous bar’s SMA2 turns downward, a buy signal is generated to go long. When SMA1 turns downward and the previous bar’s SMA2 turns upward, a sell signal is generated to go short.

The strategy uses the turning directions of two moving averages to determine the trading direction and the turning of one moving average to confirm entry timing. The dual moving average crossover ensures the trend has changed when entering the market, which helps avoid false breakouts.

Advantage Analysis

  • Using dual moving average crossover and turning points can effectively filter out false breakouts and improve entry accuracy.

  • Combining moving average turning points with the ROC indicator can clearly identify turning points and avoid frequent trading.

  • Adopting medium-to-long-term dual moving averages can track the main trend and achieve sizable trend profits.

  • The strategy logic is simple and clear, easy to understand and implement, suitable for quant trading beginners.

  • Customizable parameters suit different market environments with strong adaptability.

Risk Analysis

  • Dual moving average crossovers may generate many false signals in ranging markets, leading to losses.

  • The ROC parameters need precise optimization, otherwise turn recognition will have errors, affecting strategy performance.

  • Large periodic ranging markets may trigger stop loss multiple times. Expanding stop loss range can avoid it.

  • Relying solely on moving averages, it’s hard to respond to sudden events like major news, which may lead to losses.

  • Note the overfitting problem in parameter optimization. Test period should be long enough to include different market conditions.

Optimization Directions

  • Optimize moving average parameters to find the best moving average period combination.

  • Optimize ROC parameters to improve turning point recognition accuracy.

  • Add stop loss mechanisms such as dynamic stop loss based on breaking customized price levels.

  • Add additional conditions like volume indicators to avoid false breakouts.

  • Incorporate other indicators like MACD, BOLL to improve decision making.

  • Use machine learning etc. to auto optimize parameters and adapt to market changes.

Summary

In summary, the Dual Moving Average Turning Point strategy is a simple and practical trend following strategy. It can be implemented with basic moving average indicators and has clear, easy-to-understand logic, making it very suitable for quant trading beginners to learn and practice. With parameter optimization and stop loss optimization, the strategy stability can be greatly improved. Combining with other auxiliary indicators can further enhance the strategy. The highly customizable strategy can be flexibly applied to different market environments and is a recommended dual moving average trading strategy.

[/trans]


/*backtest
start: 2023-09-23 00:00:00
end: 2023-10-23 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("MA Turning Point Strategy", overlay=true)
src = input(close, title="Source")

price = request.security(syminfo.tickerid, timeframe.period, src)
ma1 = input(25, title="1st MA Length")
type1 = input("HMA", "1st MA Type", options=["SMA", "EMA", "HMA", "VWMA"])
f_hma(_src, _length)=>
    _return = wma((2*wma(_src, _length/2))-wma(_src, _length), round(sqrt(_length)))

price1 = if (type1 == "SMA")
    sma(price, ma1)
else
    if (type1 == "EMA")
        ema(price, ma1)
    else
        if (type1 == "VWMA")
            vwma(price, ma1)
        else
            f_hma(price, ma1)
    
plot(series=price1, style=line,  title="1st MA", color=blue, linewidth=2, transp=0)

lookback1 = input(1, "Lookback 1")
roc1 = roc(price1, lookback1)

ma1up = false
ma1down = false
ma2up = false
ma2down = false

ma1up := nz(ma1up[1])
ma1down := nz(ma1down[1])
ma2up := nz(ma2up[1])
ma2down := nz(ma2down[1])

trendStrength1 = input(2.5, title="Minimum slope magnitude * 100", type=float) * 0.01

if crossover(roc1, trendStrength1)
    ma1up := true
    ma1down := false
    
if crossunder(roc1, -trendStrength1) 
    ma1up := false
    ma1down := true

longCondition = ma1up and ma1down[1]
if (longCondition)
    strategy.entry("Long", strategy.long)

shortCondition = ma1down and ma1up[1]
if (shortCondition)
    strategy.entry("Short", strategy.short)



More