Skip to content

Instantly share code, notes, and snippets.

@soerenmartius
Created January 21, 2019 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soerenmartius/cb26c73b424d8d946c8b38995722f19d to your computer and use it in GitHub Desktop.
Save soerenmartius/cb26c73b424d8d946c8b38995722f19d to your computer and use it in GitHub Desktop.
// Let's create our own strategy
var strat = {};
// Prepare everything our strat needs
strat.init = function () {
this.addIndicator('longHMA', 'HMA', this.settings.long);
this.addIndicator('shortHMA', 'HMA', this.settings.short);
}
// Based on the newly calculated
// information, check if we should
// update or not.
strat.check = function (candle) {
const shortSignal = this.indicators.shortHMA.result;
const longSignal = this.indicators.longHMA.result;
// go long if daily close is above the hma80
if (candle.close > longSignal) {
this.advice('long');
}
// go short if daily close is above the hma55
if (candle.close < shortSignal) {
this.advice('short');
}
}
module.exports = strat;
@Mangdar
Copy link

Mangdar commented Nov 1, 2021

Hello can i see your HMA calculator ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment