Type/to search

Moving Average Divergence Strategy

Cryptocurrency
Created: 2024-01-24 11:43:41
Last modified: 2 years ago
1
Follow
1776
Followers

img

Overview

This strategy detects divergences between price and moving average line, and uses them as buy and sell signals. It can be applied to any oscillator to find divergences. This is a valuable tool that can be used for backtesting and live trading.

Strategy Logic

  1. Calculate Moving Average (MA) of length Len
  2. Detect pivot low (PL) and pivot high (PH) points of MA
  3. Check for bullish divergence: price makes new low but MA does not or MA makes new low but price does not
  4. Check for bearish divergence: price makes new high but MA does not or MA makes new high but price does not
  5. Buy and sell based on divergence

Advantage Analysis

  1. Automatically detect divergences between price and MA, avoid manual judgment errors
  2. Applicable to any oscillator, strong extensibility
  3. Can be used to backtest and validate profitability
  4. Configurable parameters to adjust sensitivity and avoid false signals
  5. Provide multiple divergence types for accurate and comprehensive judgment

Risk Analysis

  1. Invalid oscillator settings may generate excessive false signals
  2. Valid pivot points required before divergence occurs, signals may be insufficient
  3. Need to adjust parameters to balance sensitivity and filter false signals
  4. Works better combined with other factors, relatively low confidence when used alone

Optimization Directions

  1. Optimize MA parameters to find best parameter combinations
  2. Combine with other indicators like volume to avoid false signals
  3. Add machine learning model to judge divergence credibility
  4. Add risk management mechanisms to control per trade loss

Summary

This strategy uses divergences between price and MA as trading signals for automated judgment to avoid subjective errors. It can be widely applied to any oscillator with strong extensibility. Requires parameter optimization and usage with other indicators to significantly improve signal reliability and system stability.

Source
Pine
/*backtest
start: 2023-12-24 00:00:00
end: 2024-01-12 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/
// © tista 
//https://www.tradingview.com/u/tista/#published-scripts
Strategy parameters
Strategy parameters
Backtest Start Year
Backtest Start Month
Backtest Start Day
Backtest Stop Year
Backtest Stop Month
Backtest Stop Day
MA Period
MA Source
Pivot Lookback Right
Pivot Lookback Left
Max of Lookback Range
Min of Lookback Range
Plot Bullish
Plot Hidden Bullish
Plot Bearish
Plot Hidden Bearish
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)