Skip to content

Commit

Permalink
small tweaks to strats & strat docs
Browse files Browse the repository at this point in the history
  • Loading branch information
askmike committed Oct 13, 2016
1 parent 1fc9170 commit 4bf5589
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/baseTradingMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Base.prototype.propogateTick = function() {
this.update(this.candle);
if(this.requiredHistory <= this.age) {
this.log();
this.check();
this.check(this.candle);
}
this.processedTicks++;

Expand Down
17 changes: 14 additions & 3 deletions docs/trading_bot/creating_a_trading_method.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,37 @@ In these functions you write your trading method. To help you with this Gekko ha

### Indicators

Gekko supports a few indicators natively, but supports integration with the great library [TA-lib](http://ta-lib.org/).

#### Example usage

If you want to use an indicator you can add it in the `init` function and Gekko will handle the updating for you on every candle (before the update and before the check call):

// add a native indicator
this.addIndicator('name', 'type', parameters);

or

// add a TA-lib indicator
this.addTalibIndicator('name', 'type', parameters);

The first parameter is the name, the second is the indicator type you want and the third is an object with all indicator parameters. If you want an MACD indicator you can do it like so:

In your init method:

// add a native indicator
var parameters = {short: 10, long: 20, signal: 9};
this.addIndicator('mymacd', 'MACD', parameters);
this.addIndicator('mynativemacd', 'MACD', parameters);

// add a TA-lib indicator
var parameters = {optInFastPeriod: 10, optInSlowPeriod: 21, optInSignalPeriod: 9};
this.addIndicator('mytalibmacd', 'MACD', parameters);

In your check or update method:

var result = this.indicators.mymacd.result;
var result = this.indicators.mytalibmacd.result;

Currently supported native indicators can be found [here](https://github.com/askmike/gekko/tree/stable/methods/indicators), all talib indicators (100+) can be found [here](http://ta-lib.org/function.html).
See the [TA-lib indicators](https://github.com/askmike/gekko/blob/stable/docs/trading_bot/talib_indicators.md) document for a list of all suppported TA-lib indicators and there required parameters.

### Configurables

Expand Down
4 changes: 2 additions & 2 deletions methods/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ method.update = function(candle) {

// For debugging purposes.
method.log = function() {
log.debug('calculated random number:');
log.debug('\t', this.randomNumber.toFixed(3));
console.log('calculated random number:');
console.log('\t', this.randomNumber.toFixed(3));
}

// Based on the newly calculated
Expand Down

0 comments on commit 4bf5589

Please sign in to comment.