Type/to search

Long and Short Opening Strategy Based on Multi Timeframe Moving Average and MACD

Common strategy
Created: 2024-01-03 12:15:46
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

This strategy takes full advantage of the functions of the multi timeframe exponential moving average (MTF EMA) to determine the trend direction and the MACD indicator to generate trading signals, while setting stop loss and take profit prices with the ATR indicator. The strategy is suitable for digital and fiat currency pairs with strong trends and performs better in markets with strong trends.

Strategy Principle

1. Trend Judgment Using MTF EMA

The multi timeframe exponential moving average (MTF EMA) can display moving averages of multiple timeframes on the same chart to determine the overall long/short status of an asset. This strategy adopts 1-hour and 15-minute MTF EMAs.

When the price is above the 1-hour MTF EMA and the 1-hour MTF EMA is below the 15-minute MTF EMA, it is defined as an uptrend. When the price is below the 1-hour MTF EMA and the 1-hour MTF EMA is above the 15-minute MTF EMA, it is defined as a downtrend.

2. MACD Generating Trading Signals

When the MACD line crosses above the Signal line from below, a buy signal is generated. When it crosses below from above, a sell signal is generated. At the same time, a crossover limit is set for the MACD line and Signal line to avoid false signals.

3. Setting Stop Loss and Take Profit with ATR

The ATR indicator is used to set stop loss and take profit prices. ATR can dynamically set reasonable stop loss and take profit distances based on market volatility. At the same time, the multiples of stop loss and take profit are set based on the backtest of highs and lows to make them more flexible.

Trading Strategy

Open Positions Signals

Long signal: Uptrend and MACD crossing above Signal line and crossover value less than limit
Short signal: Downtrend and MACD crossing below Signal line and crossover value greater than limit

Close Positions Signals

Long take profit: Price breaks through ATR take profit price
Long stop loss: Price breaks through ATR stop loss price
Short take profit: Price breaks through ATR take profit price
Short stop loss: Price breaks through ATR stop loss price

Advantage Analysis

The biggest advantage of this strategy is that it fully utilizes the strengths of the MTF EMA in determining trends and the MACD in generating trading signals. MTF EMA can clearly judge the overall trend direction and avoid frequent trading in choppy markets. The MACD indicator can better capture short-term changes in price patterns and generate trading signals. Using both together ensures capturing the trend while obtaining more trading opportunities. In addition, using the ATR indicator to dynamically track stop loss and take profit can effectively control the risk of individual trades.

Risks and Solutions

There are two main risks to this strategy: First, in the absence of a clear trend, MTF EMA may generate incorrect signals, leading to losses; Second, the MACD indicator often generates misleading signals when prices change dramatically, which can lead to over-trading. For the first risk, the MTF EMA parameters can be adjusted appropriately to better match price trend changes; The second risk can be mitigated by setting crossover limits for the MACD indicator.

Optimization Directions

The following aspects of the strategy could be optimized:

  1. Adjust the cycle parameters of MTF EMA to match the price characteristics of different trading instruments better

  2. Optimize the fast and slow moving average and signal line parameters of the MACD indicator for better signals

  3. Test different ATR cycle parameters and stop loss/take profit multiples for the best returns

  4. Add other auxiliary indicators to filter signals

Summary

This long and short opening strategy combines the methods of MTF EMA for trend judgment, MACD for trading signal generation, and ATR for dynamic stop loss and take profit. It can achieve good returns in markets with obvious trends. There is plenty of room for optimizing this strategy's parameters and optimization to achieve better performance. However, it is necessary to control risks and avoid blind trading in choppy markets.

Source
Pine
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
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/
// © Steven A. Zmuda Burke / stevenz17
//@version=4
// From Date Inputs
Strategy parameters
Strategy parameters
From Day
From Month
From Year
To Day
To Month
To Year
═════════════════════ SOURCE ═════════════════════
Source hl2 or (open+close)/2 ?
════════════════════ MTF EMA ════════════════════
MTF EMA 1
EMA Period 1
MTF EMA 2
EMA Period 2
═════════════════════ MACD ══════════════════════
MACD fast moving average
MACD slow moving average
MACD signal line moving average
MACD EMA period
Use EMA (otherwise SMA)
Use normal MACD
LONG MACD and signal crossover limit
Show MACD ribbon?
MACD ribbon multiplier
═══════════════════ STOCHASTIC ════════════════════
Stochastic On?
K
D
Smooth
Stoch value crossover
avg price length
═════════════════ LONG SL ═════════════════
Max Intraday Loss(%)
Long Stop Loss when MTF EMA cross?
Long Stop Loss (%) on?
Long Stop Loss (%)
Long Stop Loss ATR?
Look back for High/Lows?
How far to look back for High/Lows:
Long ATR Lenghth
Long ATR Stop x ?
═════════════════ LONG TP ═════════════════
Long Take Profit (%) on?
Long Take Profit (%)
1 Long Take Profit On?
Look back for High/Lows?
How far to look back for High/Lows for 1 TP
Long ATR Lenghth 1 TP
First Long ATR Take Profit x ?
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)