Proper stop losses coming soon
#26
Quote:if the EMA cross's over or RSI signals a buy start trailing the bid price down by a percent once the bid price starts moving up go long and set a stop-loss on profit.

So once you detect your initial buy signal you want to to have some form of a trailing mechanism that confirms the signal? Most example strategies in Gekko come with a "persistence" system, that checks if the buy signal persists for X candles. Note that this is all implemented directly inside the strategy.


Quote:So far I've copied and renamed trailingStop.js to trailingStopDown.js and reversed the logic on line 27 and 33. But i'm having a hard time getting it to trigger without a long advice signal. If the logic of what I'm trying to do makes sense is it possible to trail the price down on a indicator signal then buy when the bid price goes back up?

I would advice against this: in order to have trailing stoplosses I had to implement them in a lot of places in the gekko codebase:

- I had to create the base class.
- I had to wrap that in the paper trader (based on 1min candles)
- I had to wrap that in the real trader (based on ticker polls)
- I had to introduce new gekko events
- I had to handle all the logic around: if a strat signalled a buy with a stoploss, set it up and listen to it triger.
- if before it triggered the strategy signaled a sell clean it up.
- make sure to always update local state after it triggers so gekko is aware that the exposure reversed without a trade signal (but a trailing stop trigger).

It took me a while and there were a ton of bugs, some I was able to shield with unit tests but I still get bug reports here and there.

As though why the trailing stops only go one way now: Gekko is build on some core assumptions, one being that signaling a LONG is risky (since you are about to buy into exposure) but signalling a SHORT is not (since you are selling out of exposure).


-----


In your case I would stick all the required logic inside your strategy and only signal LONG when you are sure (with your own trailing logic). You can definitely hack the trailingStop class I created, but I would import it into your strategy and don't monkey patch it into gekko!
  Reply


Messages In This Thread
Proper stop losses coming soon - by askmike - 07-07-2018, 07:27 AM
RE: Proper stop losses coming soon - by TCMabe - 07-11-2018, 08:38 PM
RE: Proper stop losses coming soon - by askmike - 07-12-2018, 04:23 AM
RE: Proper stop losses coming soon - by mark.sch - 07-12-2018, 04:41 PM
RE: Proper stop losses coming soon - by askmike - 07-13-2018, 01:36 AM
RE: Proper stop losses coming soon - by mark.sch - 07-13-2018, 09:53 AM
RE: Proper stop losses coming soon - by askmike - 07-13-2018, 12:50 PM
RE: Proper stop losses coming soon - by Kris191 - 07-30-2018, 03:37 PM
RE: Proper stop losses coming soon - by askmike - 07-31-2018, 12:56 PM
RE: Proper stop losses coming soon - by askmike - 08-11-2018, 07:32 AM
RE: Proper stop losses coming soon - by PapoKarlo - 08-12-2018, 10:12 AM
RE: Proper stop losses coming soon - by mark.sch - 08-12-2018, 11:50 AM
RE: Proper stop losses coming soon - by askmike - 08-12-2018, 02:35 PM
RE: Proper stop losses coming soon - by askmike - 08-14-2018, 04:06 AM
RE: Proper stop losses coming soon - by PapoKarlo - 08-14-2018, 04:42 PM
RE: Proper stop losses coming soon - by askmike - 08-14-2018, 04:47 PM
RE: Proper stop losses coming soon - by mark.sch - 08-16-2018, 09:24 AM
RE: Proper stop losses coming soon - by askmike - 08-16-2018, 04:04 PM
RE: Proper stop losses coming soon - by mark.sch - 08-17-2018, 10:26 PM
RE: Proper stop losses coming soon - by askmike - 08-27-2018, 11:49 AM
RE: Proper stop losses coming soon - by askmike - 08-27-2018, 12:27 PM
RE: Proper stop losses coming soon - by mark.sch - 09-06-2018, 11:13 PM
RE: Proper stop losses coming soon - by maxblack - 10-07-2018, 09:46 AM
RE: Proper stop losses coming soon - by mark.sch - 09-03-2018, 12:20 AM
RE: Proper stop losses coming soon - by askmike - 09-03-2018, 04:58 AM
RE: Proper stop losses coming soon - by mark.sch - 09-04-2018, 01:11 PM
RE: Proper stop losses coming soon - by BotsEdge - 09-09-2018, 11:25 PM
RE: Proper stop losses coming soon - by askmike - 09-06-2018, 05:14 AM
RE: Proper stop losses coming soon - by bitsnpcs - 09-11-2018, 11:55 PM
RE: Proper stop losses coming soon - by Presunto - 09-27-2018, 12:43 PM
RE: Proper stop losses coming soon - by askmike - 09-28-2018, 04:16 AM
RE: Proper stop losses coming soon - by askmike - 10-20-2018, 06:14 AM
RE: Proper stop losses coming soon - by askmike - 10-22-2018, 04:26 AM
RE: Proper stop losses coming soon - by askmike - 11-11-2018, 05:01 AM
RE: Proper stop losses coming soon - by askmike - 11-14-2018, 11:15 AM
RE: Proper stop losses coming soon - by askmike - 01-03-2019, 09:05 AM
RE: Proper stop losses coming soon - by askmike - 01-03-2019, 05:28 PM
RE: Proper stop losses coming soon - by hitripley - 01-18-2019, 02:46 PM
RE: Proper stop losses coming soon - by hitripley - 01-18-2019, 03:18 PM

Forum Jump:


Users browsing this thread: