Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

⚡️ New trend detection hilbert transform #78

Conversation

raftersvk
Copy link
Contributor

No description provided.

@raftersvk
Copy link
Contributor Author

raftersvk commented Jun 26, 2021

Hi,

following the first idea of using SAR to improve trend detection I decided to give a go at another indicator :
Hilbert Transform Trend vs Cycle
https://www.tradingpedia.com/videos/trend-vs-cycle-mode-understanding-hilbert-transform/

below is my first test of 800 epoch without ROI and trailing in order to really compare the buy sell impact.

here is a comparison of the best results : New Trend on the left side / Vanilla (ADX) on the right side

  • first we can not see a big difference on total profit
  • but average duration seems better for the same kind of profit
    image

this is confirmed when looking at epoch with duration less than a day :
image

detailed files / log here :
MGM_v012_HTTrend_comparison.zip

@raftersvk raftersvk marked this pull request as ready for review June 26, 2021 21:54
@Rikj000 Rikj000 linked an issue Jun 27, 2021 that may be closed by this pull request
@Rikj000 Rikj000 added Feature - Enhancement Update or improvement to existing feature Planned Planned feature, improvement or bugfix (not being worked on yet) labels Jun 27, 2021
@raftersvk
Copy link
Contributor Author

raftersvk commented Jun 27, 2021

there is probably one improvment on this trend detection by avoiding setting the trend which last only one candle as seen below :
image

if anyone can help me do that ;)

even further : could the trend "duration" be an hyperotable parameter ?

@Rikj000
Copy link
Owner

Rikj000 commented Jun 27, 2021

there is probably one improvement on this trend detection by avoiding setting the trend which last only one candle as seen below
if anyone can help me do that ;)

I'm thinking perhaps we could do this particular improvement at a later time! When I implement: #44
Once the features are in place to make multiple candle usage easy, then we could use our core trend indicator at larger candles, which should yield robuster / slower moving trends. I think that should reduce this issue from occuring 🙂

@Rikj000
Copy link
Owner

Rikj000 commented Jun 29, 2021

Good spot! 😄 But this will require new tests then! 👀

@raftersvk
Copy link
Contributor Author

indeed, so here are the latest results of the night ;)

total profit comparison : SharpeLoss newTrend left / SharpeLoss Vanilla right
image
=> total profit is not so good as first test, but not that far from vanilla either

epochs lasting less than a day :
image
=> still better result than vanilla, but not as strong as first test

epoch during between 24h and 48h :
image
=> tendency for shorter duration and better result is confirmed here with newTrend

files / log here :
MGM_v012_noRoiNoTrail_Sharpe_HTTREND_v2.zip

@raftersvk
Copy link
Contributor Author

raftersvk commented Jun 30, 2021

same analysis with SortinoLoss instead of Sharpe vs Vanilla(Sharpe)

total profit
image
=> still competitive new trend

epochs < 24h
image
=> new trend better and also better than SharpeLoss (not sure what it means or if it only depends of the timerange)

epochs >= 24h < 48h
image
=> still better than vanilla but not as good as Sharpe this time

files / log :
MGM_v012_noRoiNoTrail_Sortino_HTTREND_v2.zip

@raftersvk
Copy link
Contributor Author

to complete the picture here is a plot of the underlying trend detection :

  • subplot 1 : HT Trend
  • subplot 2 : resulting MGM Trend (-1 = downwards / 0 = sideways / 1 = upwards)
  • subplot 3 : plusDI / minusDI (to get the direction of the trend)

image

@raftersvk
Copy link
Contributor Author

raftersvk commented Jul 1, 2021

continuing my research, this is a new plot with the following config :
"trading_during_trends": {
"buy_trades_when_downwards": false,
"buy_trades_when_sideways": false,
"buy_trades_when_upwards": true,
"sell_trades_when_downwards": true,
"sell_trades_when_sideways": true,
"sell_trades_when_upwards": true
}

on a big picture it looks like we can avoid the big falls, but also miss some of the rebound in the downtrend.
image

freqtrade-plot-BTC_USDT-1h.zip

let's see what we get with different setups ;)

@Rikj000 Rikj000 added this to the v0.13.0 milestone Jul 2, 2021
@Rikj000 Rikj000 added In Progress This is being worked on and removed Planned Planned feature, improvement or bugfix (not being worked on yet) labels Jul 3, 2021
@Rikj000
Copy link
Owner

Rikj000 commented Jul 3, 2021

Merged with: #79

@Rikj000 Rikj000 closed this Jul 3, 2021
@Rikj000 Rikj000 removed the In Progress This is being worked on label Jul 3, 2021
@raftersvk raftersvk deleted the new-trend-detection-HilbertTransform branch July 4, 2021 18:18
@Rikj000 Rikj000 changed the title New trend detection hilbert transform ⚡️ New trend detection hilbert transform Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature - Enhancement Update or improvement to existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐞 Better core trend indicator for trend detection
3 participants