sell if price>x or sell if price<y - 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: sell if price>x or sell if price<y (/thread-57049.html) |
sell if price>x or sell if price<y - MoneyNeverSleeps - 05-01-2018 I know a minimal amount of coding and I'm basically trying to set up simultaneous stop loss and take profit orders. So for example, if the price of BTC becomes higher than 9500 USDT, I want to market sell my BTC position. Likewise, if it drops to below 8500, I also wanna sell it at market price as well. I want to keep my position as long as the price stays in this range. The below code I attempted to use gives the 'child process has dies' error. What's wrong with it? Can somebody help? var strat = {}; // Prepare everything our strat needs strat.init = function() { // setting take profit price this.proPrice = 9500; // setting stop loss price this.losPrice = 8500; } strat.check = function(candle) { if(candle.close <= this.losPrice) { this.advice(“short”); return; } if(candle.close >= this.proPrice) { this.advice(“short”); return; } } module.exports = strat; RE: sell if price>x or sell if price<y - susitronix - 05-02-2018 Hi If this is the whole code then it could not work The strat needs some basics: Code: var method = {}; You need also to initialize some var (like drivers added in the beginnig of the strat: Code: var _ = require('lodash'); The full BASSic tulip RSI strat: Code: /* Code: [RSI] You can erase and copie/paste your code to it. If you dont know about how to use these examples please watch my tutorials, about how to build a strat: TUT #1 RSI |