Ive been doing a fair amount of thought on this and this is what ive come up with
(however im not sure why you have price[1] and price [0])
Wanting to take a buy position when the 2 MA’s have crossed…
ma[0] = Daily moving average of say 10
ma[1] = Daily moving average of 30
price > ma[0] && price > ma[1]
Buy
Else - Hold
I think i can workout how to do that…
However what i cant seem to workout is how to do a trailing stop or even a stoploss based on the buy price.
I want to also be able to do a take profit at x amount of points… But haven’t been able to get that to work either.
Are you able to shed some light on what i can do?
I’ve read the API Data on Gemini and Cryptocompare back to front and cant find anything that will work.
Below is the last thing i tried to get it to take a profit, but that didnt work.
indicators.hourlyMovingAverage("BTC","USD",1,function(ma){
exchange.bitcoinPrice()
.then(response => {
var price = response.last;
console.log("MA: ", ma);
console.log("Price ", price);
if(price > ma && !hasPosition){
console.log("BUY!")
exchange.marketBuyBitcoin()
.then(response=>{
console.log("Buy succsesful")
hasPosition = true;
setTimeout(strategy, 1000);
// **** ALWAYS make sure setTimeout is within the function otherwise it wont work properly *****
})
.catch(error => console.error)
}
else if (price > ma && hasPosition && sell100higher){
function sell100higher(){
exchange.bitcoinPrice() += 10
};
console.log("SELLL!")
exchange.marketSellBitcoin()
.then(response=>{
console.log("Sell succsesful")
hasPosition = false;
setTimeout(strategy, 1000);
// **** ALWAYS make sure setTimeout is within the function otherwise it wont work properly *****
})
.catch(error => console.error)
}