Gekko Forum
Need some help to create strategy - Printable Version

+- Gekko Forum (https://forum.gekko.wizb.it)
+-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html)
+--- Forum: Strategy Development (https://forum.gekko.wizb.it/forum-12.html)
+--- Thread: Need some help to create strategy (/thread-57.html)



Need some help to create strategy - sweetpearl - 01-20-2018

Hello Gekko...!!!
I Love Gekko so much and i appreciated.
i want to implement a strategy that depend on price of coin, for example: if bitcoin hits 12000 dollar threshold i want to purchase .5 btc. and set flag to sell position hold it for second threshold that is 13500 and sell .5 bitcoin for 13500 dollar. after that set flag to buy position again.

any help will be appritiated...

Regards:
Sweet


RE: Need some help to create strategy - laravellously - 01-21-2018

Hi, this strategy will only work in an uptrend. What about a downtrend? What if the price dropped to $9850, after you bought at $12,000. See? But if you still want the strategy, I can guide you through it.


RE: Need some help to create strategy - c86s - 01-25-2018

There is a sample on the website.

// Let's create our own buy and sell strategy
var strat = {};

// Prepare everything our strat needs
strat.init = function() {
// setting buy price
this.buyPrice = 2000;

// setting sell price
this.sellPrice = 2500;
}

// What happens on every new candle?
strat.update = function(candle) {
// your code!
}

// For debugging purposes.
strat.log = function() {
// your code!
}

// Based on the newly calculated
// information, check if we should
// update or not.
strat.check = function(candle) {
// buy when it hits buy price
if(candle.close <= this.buyPrice) {
this.advice("long");
// do some output
console.log("buying BTC @", candle.close);
return;
}

// sell when it hits sell price
if(candle.close >= this.sellPrice) {
this.advice("short");
// do some output
console.log("selling BTC @", candle.close);
console.log("Profit:", (candle.close-this.buyPrice));
return;
}
}

module.exports = strat;


I am trying to use it myself, the only problem i have is for buying, it does not place the order at the expected price.
For example, lets say the price is setup for buy at $3.002, it will submit the order for 3, instead of 3.002.
Does anyone know why this is?


RE: Need some help to create strategy - patelfilms@gmail.com - 06-19-2018

How to add stoploss into above example?
If I add variable this.stopPrice=1950;
What should be in the function? Please help.

If( .... ){
}


RE: Need some help to create strategy - susitronix - 06-19-2018

@patelFilm
hi
it would be useful to use Boolean logic in order to declare the states.
if (this.stopState ==true)
     {trigger your stoploss}

i made a tutorial about my dynamique stoploss
TUT#5

maybe you find also usfull stuff in my other tutorials:
TUT#1 BASSic RSI (very basix)


implementing indicators from the Tulip library
TUT#4


RE: Need some help to create strategy - susitronix - 06-19-2018

@sweetpearl
hi
thats a nice idee but you could make it Dynamique by using a very simple procent calculation out of the candle.price (of intrest..high...low...close).

you would store the goLong/goShort price and make +-% price out of it, instead of a fixed price.
the procentage can be set in the settings...
>>>for goLong and goShort

if you are new to javascript you could look at my tutorials:

TUT#1
TUT#4
TUT#5

if you stuck in coding let the blog know to get some help