devxpy

MACD histogram relative open/close

devxpy 업데이트됨   
Prelude

This script makes it easy to capture MACD Histogram open/close for automated trading.

There seems to be no "magic" value for MACD Histogram that always works as a cut-off for trade entry/exit, because of the variation in market price over time.

The idea behind this script is to replicate the view of the MACD graph we (humans) see on the screen, in mathematics, so the computer can approximately detect when the curve is opening/closing.

Math

The maths for this is composed of 2 sections -

1. Entry -

i. To trigger entry, we normalize the Histogram value by first determining the lowest and highest values on the MACD curves (MACD, Signal & Hist).
ii. The lowest and highest values are taken over the "Frame of reference" which is a hyperparameter.
iii. Once the frame of reference is determined, the entry cutoff param can be defined with respect to the values from (i) (10% by default)


2. Exit

To trigger an exit, a trader searches for the point where the Histogram starts to drop "steeply".

To convert the notion of "steep" into mathematics -

i. Take the max histogram value reached since last MACD curve flip
ii. Define the cutoff with reference to the value from (i) (30% by default)

Plots

Gray - Dead region
Blue - Histogram opening
Red - Histogram is closing


Notes

A good value for the frame of reference can be estimated by looking at the timescale of the graph you generally work with during manual trading.
For me, that turned out to be ~2.5 hours. (as shown in the above graph)
For a 3-minute ticker, frame of reference = 2.5 * 60 / 3 = 50
Which is the default given in this script.

Ultimately, it is up to you to do grid search and find these hyperparams for the stock and ticker size you're working with.

Also, this script only serves the purpose of detecting the Histogram curve opening/closing.
You may want to add further checks to perform proper trading using MACD.
릴리즈 노트:
MACD is a good way to confirm a trend and trade on it.

The problem is that often the trend is weak. When we are watching it manually, during the entry, we can see that that gap has sufficiently opened for confirmation of a possible potential entry. However, during the algo trading, the MACD will trigger a trade entry on a minuscule gap. Often such a scenario would result in sideways movement of the market. And a sideways movement might result in loss.

To prevent this, in this script there is a confirmation on the next candle after the MACD flip, that the gap is sufficiently wide. This gives you some safety from false entry signals and saves some losses. You can change the default values to suit your trade based on backtesting.

Same way, during the exit, if you wait for the MACD crossover flip, you lose some profit, often turning profit into a loss. So, you might want to exit just before the MACD trend reversal crossover. This script offers you to exit when the MACD divergence gap is the lowest just before a possible MACD trend reversal flip over. You can change the default values to suit your trade based on backtesting.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?