Skip to content
Gekko bot resources.
JavaScript
Branch: master
Clone or download
cloggy45 Merge pull request #17 from cloggy45/dependabot/npm_and_yarn/gekko/lo…
…dash-4.17.14

Bump lodash from 4.17.11 to 4.17.14 in /gekko
Latest commit 4602707 Aug 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gekko Bump lodash from 4.17.11 to 4.17.14 in /gekko Jul 11, 2019
images Move image files into images directory Jan 25, 2018
.gitignore Updated gitignore Sep 19, 2018
README.md Updated formatting for readme Sep 19, 2018

README.md

Gekko Trading Strategies

Installation

$ git clone https://github.com/cloggy45/Gekko-Bot-Resources.git
$ cp Gekko-Bot-Resources/gekko/* gekko -R
$ cd gekko
$ npm install

helper.js Guide

The helper.js includes a collection of modules that I find myself creating each time I make a strategy.

Installation

You need to add the helper.js file to the root of your Gekko folder, then add var helper = require('../helper.js'); to the top of your strategy.

Trailing Stop Loss

"A trailing stop order sets the stop price at a fixed amount below the market price with an attached "trailing" amount. As the market price rises, the stop price rises by the trail amount, but if the stock price falls, the stop loss price doesn't change, and a market order is submitted when the stop price is hit."

Instructions

We initialize our trailing stop loss in our init function in our strategy like so:

strat.init = function() {
    this.stopLoss = helper.trailingStopLoss();
    .....

We create a trailing stop anytime we make a purchase according to the various indicators we set up in our strategy.

this.stopLoss.create(somePercentage, currentPrice);

We destroy our trailing stop after any time we call this.advice('short')

this.stopLoss.destroy();

We must also check on each candle to see if our trailing stop loss has triggered, we can do it like so:

strat.check = function(candle) {
	const currentPrice = candle.close;
	if(this.stopLoss.isTriggered(currentPrice)) {
		this.advice('short');
	    this.stopLoss.destroy();
	} else {
	    this.stopLoss.update(currentPrice);
	}
	.....

We would place the above code in our check function in our strategy.

You can’t perform that action at this time.