Gekko Forum
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)

Pages: 1 2 3 4 5 6


RE: Proper stop losses coming soon - PapoKarlo - 08-12-2018

good news! thank you


RE: Proper stop losses coming soon - mark.sch - 08-12-2018

Hi Mike, I look forward to backtest this feature in conjunction with existing strategies...it is not usable in paper trader yet, correct?


RE: Proper stop losses coming soon - askmike - 08-12-2018

Quote:it is not usable in paper trader yet, correct?

Not yet! Very soon though!


RE: Proper stop losses coming soon - askmike - 08-14-2018

@mark.sch

Trailing stops are now available in the paper trader plugin (meaning in both "paper trader" and "backtesting" mode). Note that this is all highly experimental and please help me test to make sure the numbers add up and it performs as expected Smile


RE: Proper stop losses coming soon - PapoKarlo - 08-14-2018

(08-14-2018, 04:06 AM)askmike Wrote: @mark.sch

Trailing stops are now available in the paper trader plugin (meaning in both "paper trader" and "backtesting" mode). Note that this is all highly experimental and please help me test to make sure the numbers add up and it performs as expected Smile

how to activate trailing? or it active by default?


RE: Proper stop losses coming soon - askmike - 08-14-2018

Quote:how to activate trailing? or it active by default?

It's quite technical at the moment:

1. stop losses are triggers that can be defined in a strategy, once. they are finished I might be adding them to some default strategies. Up until that point they are a tool for people who create strategies, see here: https://github.com/askmike/gekko/blob/2cd49b65d90259d0a8e03c3f76126f12c2e95c63/docs/strategies/creating_a_strategy.md#check-function
2. It's not part of any stable release yet, you manually need to download the feature branch if you want to test this in your own strategies.


RE: Proper stop losses coming soon - mark.sch - 08-16-2018

I did a quick test by adding the trailing stoploss trigger into my strategy:

           this.advice({ 
              direction: 'long', 
              trigger: { 
                type: 'trailingStop', 
                trailPercentage: 3 
              } 
            }); 

Unfortunately  during backtest I get errors that the trailValue does not get calculated correctly...I gave it trailPercentage. So backtest result is the same - SL is not applied.

2018-08-15 23:02:49 (INFO):    [StratRunner] Trailing stop trail value 

specified as percentage, setting to: NaN undefined 

2018-08-15 23:02:49 (WARN):    [Papertrader] ignoring trailing stop 
without trail value 

I saw you moved trigger things into GB, is the advice usage still valid?


RE: Proper stop losses coming soon - askmike - 08-16-2018

Quote:I saw you moved trigger things into GB, is the advice usage still valid?

Yes, format has not changed.

Quote:Unfortunately during backtest I get errors that the trailValue does not get calculated correctly...I gave it trailPercentage. So backtest result is the same - SL is not applied.

Ah I caught this as well, I pushed a lot of new code a few hours back, would you mind trying again? Thanks!


RE: Proper stop losses coming soon - mark.sch - 08-17-2018

With the latest commits the backtest is running, great. Tweaking the SL values between 4-5% it was possible to raise the backtest result from +97% to +113% profit - eth/eur from the beginning of the year. Any lower stop loss value reduced the profit heavily.

This is the output:

2018-08-18 00:07:52 (INFO): 2018-01-13 13:00:00: Paper trader simulated a BUY @ 1060.00 EUR 0.00000000 EUR => 1.50022978 ETH
2018-08-18 00:07:52 (INFO): 2018-01-14 18:00:00: Paper trader simulated a SELL @ 1070.00 EUR 1602.83799580 EUR <= 0.00000000 ETH
2018-08-18 00:07:53 (INFO): [StratRunner] Trailing stop trail value specified as percentage, setting to: 42.68754
2018-08-18 00:07:53 (INFO): [StratRunner] Trailing stop trail value specified as percentage, setting to: 42.68754
2018-08-18 00:07:53 (INFO): 2018-01-20 10:00:00: Paper trader simulated a BUY @ 927.99 EUR 0.00000000 EUR => 1.72462390 ETH
2018-08-18 00:07:53 (INFO): 2018-01-21 12:00:00: Paper trader simulated a SELL @ 888.39 EUR 1529.84041858 EUR <= 0.00000000 ETH
2018-08-18 00:07:53 (INFO): [StratRunner] Trailing stop trail value specified as percentage, setting to: 40.29094
2018-08-18 00:07:53 (INFO): [StratRunner] Trailing stop trail value specified as percentage, setting to: 40.29094
2018-08-18 00:07:53 (INFO): 2018-01-25 04:00:00: Paper trader simulated a BUY @ 875.89 EUR 0.00000000 EUR => 1.74399257 ETH
2018-08-18 00:07:54 (INFO): 2018-01-26 10:00:00: Paper trader simulated a SELL @ 827.23 EUR 1440.51894922 EUR <= 0.00000000 ETH
2018-08-18 00:07:54 (INFO): [StratRunner] Trailing stop trail value specified as percentage, setting to: 40.8204
2018-08-18 00:07:54 (INFO): [StratRunner] Trailing stop trail value specified as percentage, setting to: 40.8204
2018-08-18 00:07:54 (INFO): 2018-01-27 18:00:00: Paper trader simulated a BUY @ 887.40 EUR 0.00000000 EUR => 1.62086789 ETH
2018-08-18 00:07:54 (INFO): 2018-01-29 22:00:00: Paper trader simulated a SELL @ 939.25 EUR 1520.11656543 EUR <= 0.00000000 ETH


The Stratrunner outputs "Trailing stop trail value specified as percentage, setting to: 40.8204". What does this value 40.8204 mean? This test uses a SL with 4.6%


RE: Proper stop losses coming soon - askmike - 08-27-2018

Trailing stops have now in develop! I did some initial testing but please consider this very experimental at this stage.

- How to add a trailing stop loss to a strategy: https://gekko.wizb.it/docs/strategies/creating_a_strategy.html#check-function
- New trigger events available to plugins: https://gekko.wizb.it/docs/internals/events.html#triggerCreated-event (triggerCreated, triggerFired and triggerAborted).

Quote:The Stratrunner outputs "Trailing stop trail value specified as percentage, setting to: 40.8204". What does this value 40.8204 mean? This test uses a SL with 4.6%

Trailing stop losses as implemented in Gekko trail a fixed amount: if you trade BTC and you go in @7000 you can set the trailValue to 50 to create a stoploss at 6950. It will move up together with the price, but never down -> after the price goes to 7050 you are in profit (minus fees and execution risk).

But because most people write strategies and try them out on a bunch of markets (USD/BTC, USD/ETH, BTC/ETH) requiring strategies to set this to a fixed number (of 50 for example) would only really work for USD/BTC but not for BTC/ETH (since the price is 0.10, what does 40 even mean). For those reasons Strategies can simply pass a percentage which Gekko will convert on creation to a fixed number).