Proper stop losses coming soon - Printable Version +- Gekko Forum (https://forum.gekko.wizb.it) +-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html) +--- Forum: General Discussion (https://forum.gekko.wizb.it/forum-14.html) +--- Thread: Proper stop losses coming soon (/thread-57314.html) |
RE: Proper stop losses coming soon - asympleton - 11-13-2018 Hi Mike et al. I wonder if trailing stops are working in the real trader. I tested the paper trader adding the trigger type trailingStop and it seems to affect the paper trader's results. But I'm not sure if people are actually using this live now? Also, I see some typos in the code like type: 'trialingStop' in trader.js. RE: Proper stop losses coming soon - asympleton - 11-14-2018 Another weird thing - the paper trades are showing double rows for each trade. The first row per trade shows an intra-candle exit time (so if I'm using hourly candles, it exits at some minute that's not :00). It seems like this is a triggered trailing stop. The 2nd row per trade shows the usual hourly exit time. The exit times and prices are different but the P&L and Profit (%) columns shows the same number for both rows. RE: Proper stop losses coming soon - asympleton - 11-14-2018 (08-27-2018, 12:27 PM)askmike Wrote: - If your strategy fires a SELL advice before the trigger fires, Gekko will delete the trigger. I think bug I'm seeing is that the trigger is not getting deleted. I hooked into onTrade with console.log(trade) and what I'm seeing is: trade-1 / advice-1 / buy trade-1 / advice-1 / sell trade-2 / advice-2 / sell trade-3 / advice-3 / buy trade-3 / advice-3 / sell trade-4 / advice-4 / sell As you see, two "sells" are given for each "buy". The 2nd sell happens on a new trade id, but I guess that trade doesn't actually exist (there wasn't another buy). Also, not sure if this is expected, but the adviceId is duplicated for the buy and sell, then the 2nd sell increments the adviceId. Is there any way to fix or work around this in the strategy itself or can it only be fixed in the trader plugin/code? RE: Proper stop losses coming soon - askmike - 11-14-2018 @asympleton is this the live trader or the paper trader? RE: Proper stop losses coming soon - asympleton - 11-14-2018 (11-14-2018, 11:15 AM)askmike Wrote: @asympleton is this the live trader or the paper trader? This is all in the paper trader (it seems prudent to make sure everything's working as expected on paper before going live so the problems I'm experiencing are worrying me). Is there an example of a strategy using the new 'trigger' and trailPercentage which works as expected? My advice code is just copied from what I saw (note I configure settings.trail_pct): this.advice({ direction: 'long', // or short trigger: { // ignored when direction is not "long" type: 'trailingStop', trailPercentage: settings.trail_pct // or: // trailValue: 100 } }); RE: Proper stop losses coming soon - dissertationbestuk - 12-28-2018 Nice post RE: Proper stop losses coming soon - Darksta123 - 01-02-2019 Hi @askMike hi All, first of all, thank you very much for developing this tool and making it available as open source! I really enjoy playing with it for the first few hours now! Will definetly send you some beers through the BTC address you published when I have my first strategy up and running. While implementing my first strategy, I have two specific questions where I haven't found any answer around: 1. Trailing Stop Loss: I would like to add a trailing stop loss to an existing 'long' advice/status. So the long advice has been given already and on a specific condition I would like to add a trailing stop loss to that. The first long is called just like this: Code: this.advice({ Then on a specific condition (not relevant for the example here), I would like to add the trailing stop loss like this, by calling the 'long' advice again: Code: this.advice({ However, when I do this, the trailing stop loss does not work/execute! Is there another way how to add a trailing stop loss on an existing 'long' direction? 2. Trailing Stop Buy? I would like to use a "trailing stop buy" kind of function (similar for example like the Stop Limit Buy on Binance). I would like to automatically execute a buy order as soon as the value goes up for 1% from the last candle for example. But I would not like to wait for the next full candle (15min in my case) but instead would like to execute the 'buy' based on the live price immediately (for example 1 or 2 min after the previous candle finished as the price went up 1% from that candle). Can somebody give me a hint where/how I could approach this? Many thanks in advance for help/replies!! :-) Cheers, Darksta RE: Proper stop losses coming soon - askmike - 01-03-2019 Quote:1. Trailing Stop Loss: I would like to add a trailing stop loss to an existing 'long' advice/status. So the long advice has been given already and on a specific condition I would like to add a trailing stop loss to that. Woa this is the first time I heard this request, unfortunately this is not supported yet but I will put it on my list. Right now you can only specify a trailingStop when you trigger a LONG position. Quote:2. Trailing Stop Buy? The current Gekko model completely assumes that your base position is the "currency" (in USD/BTC this is USD, in BTC/ETH this is BTC). And Gekko strategies are in a neutral position after each "short" trigger (naming here is bad, Gekko can't actually short - this just means sell back "asset" into "currency"). This means that a trailing stop is a way to manage risk: you can set it up as a way to prevent the "asset" from crashing. As for "not missing the boat" when the asset quickly goes up in price: can't you monitor the price yourself (in your strategy) and trigger a long signal when this happens? If this happens more quickly than your strategy is configured for (if you want to buy when the price goes up in 5 minutes, but you set the candle size to 60 minutes), why not adjust your strategy so it works on 5 minute intervals? RE: Proper stop losses coming soon - Darksta123 - 01-03-2019 (01-03-2019, 09:05 AM)askmike Wrote:Quote:1. Trailing Stop Loss: I would like to add a trailing stop loss to an existing 'long' advice/status. So the long advice has been given already and on a specific condition I would like to add a trailing stop loss to that. Thanks a lot askmike for your answer! Regarding 1.: It would be great if one could control the triggers for already given advice, I agree. Do you see currently (with 0.6.8) any way for me to tap into that and manipulate for example the percentage of an existing trailing stop loss (maybe even by extending the current Gekko behavior)? Lets say, I initiate always the trailing stop loss for every long advice, so the trigger exists, however start with a large percentage and gradually want to decrease it? 2. Thank you for your explanations. Yes it would be possible for me to use a shorter interval and monitor the price. As I understood the trailing stop loss is using the live price and not the candle updates to trigger the stop. I was aiming for something similar to buy that uses the live price, so is even fast than the candle updates and automatically triggers when the price moves up a specific percentage/value. Cheers, Darksta RE: Proper stop losses coming soon - askmike - 01-03-2019 Quote:Regarding 1.: It would be great if one could control the triggers for already given advice, I agree. Do you see currently (with 0.6.8) any way for me to tap into that and manipulate for example the percentage of an existing trailing stop loss (maybe even by extending the current Gekko behavior)? Lets say, I initiate always the trailing stop loss for every long advice, so the trigger exists, however start with a large percentage and gradually want to decrease it? This would be pretty hard, since the trailing stop is managed by a different part of the codebase (inside Gekko Broker). The trailing stop code supports adjusting the trail: https://github.com/askmike/gekko/blob/6546d5d383ab08d47b7dae2fafe34c588046b066/exchange/triggers/trailingStop.js#L38 But that needs to be glued through a few components so your strategy can pass a message there. A message needs to flow from: - your strategy - tradingAdvisor plugin - [ new gekko event ] - see here: https://gekko.wizb.it/docs/internals/events.html - the trader plugin - into the trailing stop If we go this route I want to completely detach the creating of a trailing stop with the triggering of a long signal (we can still support current behavior to keep everything backwards compatible). Quote:2. Thank you for your explanations. Yes it would be possible for me to use a shorter interval and monitor the price. As I understood the trailing stop loss is using the live price and not the candle updates to trigger the stop. I was aiming for something similar to buy that uses the live price, so is even fast than the candle updates and automatically triggers when the price moves up a specific percentage/value. Gekko strategy interface is very simple by design, the only lever you have is the candleSize (with a minimum of once per minute). Note that "live trailing stop" that Gekko supports isn't low latency either, it polls pretty slow once every few seconds max: https://github.com/askmike/gekko/blob/develop/exchange/trigger.js#L41 --- Gekko really isn't designed for low latency stuff. I want to move towards native stop losses for exchanges that support them, that doesn't require any effort on Gekkos part. |