Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Need help for trigger sale and buy correct #1610

Closed
lassebjo opened this issue Jan 2, 2018 · 2 comments
Closed

Need help for trigger sale and buy correct #1610

lassebjo opened this issue Jan 2, 2018 · 2 comments
Labels

Comments

@lassebjo
Copy link

lassebjo commented Jan 2, 2018

Note: for support questions, please join our Discord server

  • I'm submitting a ...
    [ ] bug report
    [ x] feature request
    [ ] question about the decisions made in the repository

  • Action taken (what you did)
    I have tried to adjust thresholds in gekko before i start the bot live, but i cant seem to get it right.

  • Expected result (what you hoped would happen)
    In gdax it uses ema 12 and ema 26. My problem that i cant seem to find the correct command to do what i want:

**- When ema 12 crosses ema 26 in a uptrend and ema 12 is 50 greather then it was when they crossed. BUY
So if ema 12 crossed ema 26 at 12000 , then i want that it buys at 12050. ( so ema12 is 50 greather then it was when they crossed.) If its not getting over 50 and are going under ema26 it dosent do anything. Then it waits for a new chance for ema 12 to cross ema 26 at another point again. Important thing is that it buys if its going over 50 then they were when it crossed.

  • When ema 12 crosses ema 26 in a downtrend and ema 12 is 50 less then the crosspoint SELL
    When ema 12 crosses ema 26 in downtrend at for example 12000 it sells if ema 12 is still going down if ema 12 is 50 less then it was at crosspoint (11950).

So its not about the market price but about det difference between ema 12 and ema 26

I have tried for daaaaays but i cant seem to get the correct command. My next problem when this is fixed is to buy and sell with limit orders .

Hoping for help.
I have deleted all i have done and trying over again. So im starting with standard example DEMA strategy and working my way from there.

By the way, great work with gekko .

This is the standard strategy DEMA:

// helpers
var _ = require('lodash');
var log = require('../core/log.js');

// let's create our own method
var method = {};

// prepare everything our method needs
method.init = function() {
this.name = 'DEMA';

this.currentTrend;
this.requiredHistory = this.tradingAdvisor.historySize;

// define the indicators we need
this.addIndicator('dema', 'DEMA', this.settings);
}

// what happens on every new candle?
method.update = function(candle) {
// nothing!
}

// for debugging purposes: log the last calculated
// EMAs and diff.
method.log = function() {
var dema = this.indicators.dema;

log.debug('calculated DEMA properties for candle:');
log.debug('\t', 'long ema:', dema.long.result.toFixed(8));
log.debug('\t', 'short ema:', dema.short.result.toFixed(8));
log.debug('\t diff:', dema.result.toFixed(5));
log.debug('\t DEMA age:', dema.short.age, 'candles');
}

method.check = function(candle) {
var dema = this.indicators.dema;
var diff = dema.result;
var price = candle.close;

var message = '@ ' + price.toFixed(8) + ' (' + diff.toFixed(5) + ')';

if(diff > this.settings.thresholds.up) {
log.debug('we are currently in uptrend', message);

if(this.currentTrend !== 'up') {
  this.currentTrend = 'up';
  this.advice('long');
} else
  this.advice();

} else if(diff < this.settings.thresholds.down) {
log.debug('we are currently in a downtrend', message);

if(this.currentTrend !== 'down') {
  this.currentTrend = 'down';
  this.advice('short');
} else
  this.advice();

} else {
log.debug('we are currently not in an up or down trend', message);
this.advice();
}
}

module.exports = method;

@lassebjo
Copy link
Author

lassebjo commented Jan 2, 2018

@askmike Sorry for tagging, but im wery eager and been sitting in front of gekko and tried all different commands for everything and trying to learn back and forth. But cant seem to get this right anyhow.

@stale
Copy link

stale bot commented Oct 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you feel this is very a important issue please reach out the maintainer of this project directly via e-mail: gekko at mvr dot me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant