forked from DeviaVir/zenbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor overhaul to trend_ema strat - added whipsaw filtering via std. …
…deviation (--neutral_rate=auto), trim preroll of sim result graph
- Loading branch information
Carlos Rodriguez
committed
May 21, 2017
1 parent
0cf5855
commit 35dde49
Showing
4 changed files
with
55 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = function container (get, set, clear) { | ||
return function stddev (s, key, length, source_key) { | ||
if (typeof s.period[source_key] === 'number') { | ||
var sum = s.period[source_key] | ||
var sum_len = 1 | ||
for (var idx = 0; idx < length; idx++) { | ||
if (typeof s.lookback[idx][source_key] === 'number') { | ||
sum += s.lookback[idx][source_key] | ||
sum_len++ | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
var avg = sum / sum_len | ||
var var_sum = 0 | ||
for (var idx = 0; idx < sum_len - 1; idx++) { | ||
var_sum += Math.pow(s.lookback[idx][source_key] - avg, 2) | ||
} | ||
var variance = var_sum / sum_len | ||
s.period[key] = Math.sqrt(variance) | ||
} | ||
} | ||
} |