-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtulip-adx.js
More file actions
30 lines (28 loc) · 795 Bytes
/
tulip-adx.js
File metadata and controls
30 lines (28 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var method = {};
// Prepare everything our method needs
method.init = function() {
this.name = 'tulip-adx'
this.trend = 'none';
this.requiredHistory = this.tradingAdvisor.historySize;
this.addTulipIndicator('myadx', 'adx', this.settings);
}
// What happens on every new candle?
method.update = function(candle) {
// nothing!
}
method.log = function() {
// nothing!
}
method.check = function(candle) {
var price = candle.close;
var adx = this.tulipIndicators.myadx.result.result;
// console.dir(adx)
if(this.settings.thresholds.down > adx && this.trend !== 'short') {
this.trend = 'short';
this.advice('short');
} else if(this.settings.thresholds.up < adx && this.trend !== 'long'){
this.trend = 'long';
this.advice('long');
}
}
module.exports = method;