OPEN-SOURCE SCRIPT

MACD by Take and Trade

Cập nhật
Improved version of MACD with asymmetrical BUY and SELL approaches.

This indicator is based on popular MACD one, but with some "tricks" designed to make it more applicable to the rapidly changing crypto market.

Key benefits:

  • Dynamic auto-adjusted threshold to filter out weak signals
  • Highlighted BUY/SELL signals with divergence (if a signal is accompanied by divergence, for example, price makes a new high while macd has a second high below the first, this signal is considered stronger and will be highlighted in a darker color)
  • Boost BUY signals on very slow market in accumulation phase
  • Not symmetric! It uses 2 different signal lines, which allows to obtain SELL signals earlier comparing to classic MACD approach


Classic concept of MACD

Classic MACD, in its simplest case, consists of two lines - macd line and signal line. Macd line is a difference between so-called "fast" and "slow" EMA lines (there are just a Exponential Moving Average lines with different windows: "12" for fast and "26" for slow). Signal line is just a smoothed "macd" line.

When macd line crosses signal line from bottom to up and intersection point < 0, this is "BUY" signal. And vise versa, when macd line crosses signal line from top to bottom, and intersection point > 0, this is "SELL" signal.

Parameters used in default configuration of classic MACD indicator:

  • Fast line: EMA-12
  • Slow line: EMA-26
  • Signal line: EMA-9


Problem of classic concept

Classic MACD indicator usually gives not bad "BUY" signals, especially if using them not for operational trading but for "investment" strategy. But "SELL" signalls usually generated too late. Simply because the market tends to fall much faster than it rises.

Possible solution (the main feature of our version of MACD)

To make indicator react faster on SELL condition, while still keeping it reliable for BUY signals, we decided to use two signal lines. Faster than default signal line (with window=6) for BUY signals and much faster than default (with window=2) for SELL signals.

This approach allowed us to receive sell signals earlier and exit deals on more favorable prices. Trade off of this change - is the number of SELL signals - there were more of them. However, this does not matter, since we receive the very first sell signal with a "very fast signal line" much earlier than with classic indicator settings.

Parameters we use in our improved MACD indicator:

  • Fast line: EMA-12
  • Slow line: EMA-24
  • Faster signal line: EMA-6
  • Much faster signal line: EMA-2


Removing noise (false triggerings)

Other drawback of classic MACD - it generates a lot of "weak" (false) signals. This signals are generated when macd crosses signal line much close to zero-line. And usually there are a lot of such intersections.

To remove this kind of noise, we added a trigger threshold, which by default is equal to 2.5% of the average asset price over a long period of time. Due to the link to the average price, this threshold automatically takes a specific value for each trading pair. Threshold 2.5% works perfect for all trading pairs for 1D timeframe. For other timeframes user can (and maybe will want) change it.

Boost weak BUY signals in a prolonged bear market

Signals on bearish stage are usually very weak, because there is no volatility, and no price impulse. And such signals will be filtered out as "noise" - see above. But this time is perfect time to buy! Therefore, we further boost the buy signals in a prolonged bear market so that they can pass through the filter and appear on the chart. Bearish period is the best time to invest!

Developed by Take and Trade. Enjoy using it!
Phát hành các Ghi chú
What's new in version 1.2:
  • Rerndering auxiliary MACD graphs are now optional, and can be enabled (or disabled) in DEBUG SETTINGS section. These graphs are not needed for most of end-users, so disabling them helps to keep the chart clean.
  • All MACD-related graphs are now have clearly recognizable titles in STYLES tab, so setting their color is much easier.


What's new in version 1.1:
  • Alerts support. Alerts is a standard feature of Trading View, but in order to generate useful alerts script should implement this functionality. Now it does! So you can set up alerts for BUY and SELL signals, and get either notification in app or email, or even external API requesting.
  • Removed "Stability check offset" settings. The purpose of this setting is not transparent enough to end users, and it does not have a "mathematical basis".
  • Added new setting instead: "Number of TFs for volatility check". Now user can specify how many recent timeframes should be analyzed for stability check. We just take SMA-200 values on this period of time and see if it strictly grows or strictly decreases, we assume volatility is gone. Maybe not the best approach for volatility check, but at least it is transparent for users.
Phát hành các Ghi chú
What's new in version 1.3:
Refactored and simplified logic for divergence detection.
Moving Average Convergence / Divergence (MACD)

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Thông báo miễn trừ trách nhiệm