Skip to content
This repository was archived by the owner on Feb 16, 2020. It is now read-only.
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed that every time we start the software it trades a position beca…
…use DEMA is undefined
  • Loading branch information
mlmurray committed Feb 11, 2014
commit 4d984a89afac002f056576aba9ce12e8c7a08ec2
12 changes: 10 additions & 2 deletions methods/DEMA.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ TradingMethod.prototype.calculateAdvice = function() {

var message = '@ ' + price.toFixed(8) + ' (' + diff.toFixed(5) + ')';
log.debug('We are currently in the trend ', this.currentTrend);

if(diff > settings.buyTreshold) {

if (this.currentTrend == undefined ) {
// We just started the program and we don't have a trend, so set it and wait until next time.
if (diff > settings.buyTreshold)
this.currentTrend = 'up';
else
this.currentTrend = 'down';
this.advice();

} else if(diff > settings.buyTreshold) {
log.debug('we are currently in uptrend', message);

if(this.currentTrend !== 'up') {
Expand Down