Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
Fix up/downtrend thresholds MACD (#223)
Browse files Browse the repository at this point in the history
* Fix up/downtrend thresholds

The thresholds were only reacting on the first period of the MACD trend. After this they did not respond as the last period was already positive or negative.

With this it will take the threshold in consideration as well.

* Uniform/Clear conditions

conditionis in the form of: if (a - t > 0 && b - t <= 0) / if (a + t < 0 && b + t >= 0)
  • Loading branch information
Fjuxx authored and DeviaVir committed Jun 6, 2017
1 parent b6cc96a commit 5238e77
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions extensions/macd/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ module.exports = function container (get, set, clear) {
}

if (typeof s.period.macd_histogram === 'number' && typeof s.lookback[0].macd_histogram === 'number') {
if (s.period.macd_histogram > s.options.up_trend_threshold && s.lookback[0].macd_histogram <= 0) {
if ((s.period.macd_histogram - s.options.up_trend_threshold) > 0 && (s.lookback[0].macd_histogram - s.options.up_trend_threshold) <= 0) {
s.signal = 'buy';
} else if (s.period.macd_histogram < -s.options.down_trend_threshold && s.lookback[0].macd_histogram >= 0) {
} else if ((s.period.macd_histogram + s.options.down_trend_threshold) < 0 && (s.lookback[0].macd_histogram + s.options.down_trend_threshold) >= 0) {
s.signal = 'sell';
} else {
s.signal = null; // hold
Expand Down

0 comments on commit 5238e77

Please sign in to comment.