Need some help to create strategy
#1
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
  Reply
#2
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.
  Reply
#3
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?
  Reply
#4
How to add stoploss into above example?
If I add variable this.stopPrice=1950;
What should be in the function? Please help.

If( .... ){
}
  Reply
#5
@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
  Reply
#6
@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
  Reply


Forum Jump:


Users browsing this thread: