Skip to content

Instantly share code, notes, and snippets.

@askmike
Created October 4, 2018 04:07
Show Gist options
  • Save askmike/42ac6986587abbf1b24cf1321a70876d to your computer and use it in GitHub Desktop.
Save askmike/42ac6986587abbf1b24cf1321a70876d to your computer and use it in GitHub Desktop.
expsoing this.advice in a gekko strat
// option 1:
const otherFunction = (candle, advice) => {
// your other function
// example:
if(something) {
advice('long');
}
}
start.check = (candle) => {
// whenever you call otherFunction simply pass the advice function
otherFunction(candle, this.advice)
}
// -------
// option 2:
const otherFunction = () => {
// your other function
}
strat.init = function() {
this.otherFunction = otherFunction.bind(this);
// and now use this.otherFunction
// it has access to this.advice
}
// ------
// option 3:
strat.init = function() {
this.otherFunction = () => {
// your other function
}
}
strat.check = function() {
this.otherFunction();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment