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

stddev calculate on period #826

Merged
merged 3 commits into from Dec 14, 2017
Merged
Changes from all commits
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
24 changes: 9 additions & 15 deletions extensions/strategies/stddev/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module.exports = function container (get, set, clear) {
this.option('min_periods', "min_periods", Number, 1250)
},
calculate: function (s) {
calculated = null
},
onPeriod: function (s, cb) {
get('lib.ema')(s, 'stddev', s.options.stddev)
var tl0 = []
var tl1 = []
Expand All @@ -25,22 +28,13 @@ module.exports = function container (get, set, clear) {
s.mean1 = math.mean(tl1)
s.sig0 = s.std0 > s.std1 ? 'Up' : 'Down';
s.sig1 = s.mean0 > s.mean1 ? 'Up' : 'Down';
}
},
onPeriod: function (s, cb) {
if (
s.sig1 === 'Down'
)
{
}
if (s.sig1 === 'Down') {
s.signal = 'sell'
}
else if (
s.sig0 === 'Up'
&& s.sig1 === 'Up'
)
{
s.signal = 'buy'
}
}
else if (s.sig0 === 'Up' && s.sig1 === 'Up') {
s.signal = 'buy'
}
cb()
},
onReport: function (s) {
Expand Down