Skip to content

Instantly share code, notes, and snippets.

@tystr
Created June 23, 2020 03:24
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 tystr/17c857a4859f6129960bb51b60521b28 to your computer and use it in GitHub Desktop.
Save tystr/17c857a4859f6129960bb51b60521b28 to your computer and use it in GitHub Desktop.
Tradovate weighted moving average script which allows setting an offset amount
const predef = require("./tools/predef");
const WMA = require("./tools/WMA");
class weightedMovingAverage {
init() {
this.wma = WMA(this.props.period);
}
map(d) {
return this.wma(d.value() - this.props.offset);
}
}
module.exports = {
name: "wma2",
description: "Weighted Moving Average (offset)",
calculator: weightedMovingAverage,
params: {
period: predef.paramSpecs.period(14),
offset: {
type: "number",
def: 2.0,
restrictions: {
step: 0.25,
min: -100.0
}
}
},
tags: [predef.tags.MovingAverage, "MY Indicators"],
schemeStyles: predef.styles.solidLine("#8cecff")
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment