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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MGM_DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This guide now assumes you have **Freqtrade** and **jq** already installed, if y
3) Do some Technical Analysis on how the global crypto market has been behaving in the last months/weeks & pick a logical timeframe to do your HyperOpt upon (The timeframe in the go-to commands for example resembles some bullish rise/correction cycles & I believe 2021 will be a bullish year thus I think it's a good timeframe to test upon).
4) HyperOpt for a **1st HyperOpt Run** with the command provided in the [Go-To Commands](#go-to-commands) (Free to alter the command if you have a good idea that you want to test)
The 1st HyperOpt Run *(When no `mgm-config-hyperopt.json` exists)* is automatically ran with the default open search spaces ranging between the default `min_` & `max_` values provided under the `monigomani_settings` section of `mgm-config.json`
5) **[Reflect over your HyperOpt results!]((#reflect-over-hyperopt-results))** The computer just tries to get certain values high (profits) and others low (losses), without a true understanding of their meaning. Because of this HyperOpt is prone to profit exploitation which would be no good when used Live. That's why you need to make yourself familiar with possible [BackTesting-Traps](https://brookmiles.github.io/freqtrade-stuff/2021/04/12/backtesting-traps/). Only then you can tell which results would make sense and would be any good when used Live.
5) **[Reflect over your HyperOpt results!](#reflect-over-hyperopt-results)** The computer just tries to get certain values high (profits) and others low (losses), without a true understanding of their meaning. Because of this HyperOpt is prone to profit exploitation which would be no good when used Live. That's why you need to make yourself familiar with possible [BackTesting-Traps](https://brookmiles.github.io/freqtrade-stuff/2021/04/12/backtesting-traps/). Only then you can tell which results would make sense and would be any good when used Live.
You can check a certain epoch in the list of best results using:
```powershell
freqtrade hyperopt-show -n <epoch of choice>
Expand Down Expand Up @@ -532,4 +532,4 @@ You still need to install [jq](https://stedolan.github.io/jq/)
### ValueError: the lower bound X has to be less than the upper bound Y
You probably ran with precision different from 1. If so then you need to run your 1st HO Run results through the calculator with `-pu` or `--precision-used` and then fix up your `mgm-config-hyperopt.json` with the adjusted results before firing up the 2nd HO Run.

Check out the documentation for the [Precision Setting](#precision-setting) and the [Total Overall Signal Importance Calculator](#total-overall-signal-importance-calculator)!
Check out the documentation for the [Precision Setting](#precision-setting) and the [Total Overall Signal Importance Calculator](#total-overall-signal-importance-calculator)!
16 changes: 12 additions & 4 deletions user_data/strategies/MasterMoniGoManiHyperStrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,21 @@ def _populate_core_trend(self, dataframe: DataFrame, metadata: dict) -> DataFram
# -DM (Negative Directional Indicator) = previous low - current low
dataframe['minus_di'] = ta.MINUS_DI(dataframe, timeperiod=25)

# Hilbert Transform - TrendvsCycle
dataframe['HT_TRENDMODE'] = ta.HT_TRENDMODE(dataframe)

# Parabolic SAR
dataframe['sar'] = ta.SAR(dataframe)

# Trend Detection
# ---------------
dataframe.loc[(dataframe['HT_TRENDMODE'] == 1) & (dataframe['sar'] > dataframe['close']), 'trend'] = 'downwards'
dataframe.loc[(dataframe['HT_TRENDMODE'] == 0) | (dataframe['sar'] == dataframe['close']), 'trend'] = 'sideways'
dataframe.loc[(dataframe['HT_TRENDMODE'] == 1) & (dataframe['sar'] < dataframe['close']), 'trend'] = 'upwards'

# Detect if current trend going Downwards / Sideways / Upwards, strategy will respond accordingly
dataframe.loc[(dataframe['adx'] > 22) & (dataframe['plus_di'] < dataframe['minus_di']), 'trend'] = 'downwards'
dataframe.loc[dataframe['adx'] <= 22, 'trend'] = 'sideways'
dataframe.loc[(dataframe['adx'] > 22) & (dataframe['plus_di'] > dataframe['minus_di']), 'trend'] = 'upwards'
dataframe.loc[(dataframe['trend'] == "downwards"), 'MGM_Trend'] = -1
dataframe.loc[(dataframe['trend'] == "sideways"), 'MGM_Trend'] = 0
dataframe.loc[(dataframe['trend'] == "upwards"), 'MGM_Trend'] = 1

return dataframe

Expand Down
9 changes: 8 additions & 1 deletion user_data/strategies/MoniGoManiHyperStrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ class MoniGoManiHyperStrategy(MasterMoniGoManiHyperStrategy):
'ema200': {'color': '#074b36'},
'bb_upperband': {'color': '#6f1a7b'},
'bb_lowerband': {'color': '#6f1a7b'},
'vwap': {'color': '#727272'}
'vwap': {'color': '#727272'},
'sar': {'color': '#2c05f6'}
},
'subplots': {
# Subplots - Each dict defines one additional plot (MACD, ADX, Plus/Minus Direction, RSI)
'MGM Trend': {
'MGM_Trend': {'color': '#7fba3c'}
},
'MACD (Moving Average Convergence Divergence)': {
'macd': {'color': '#19038a'},
'macdsignal': {'color': '#ae231c'}
Expand All @@ -118,6 +122,9 @@ class MoniGoManiHyperStrategy(MasterMoniGoManiHyperStrategy):
},
'RSI (Relative Strength Index)': {
'rsi': {'color': '#7fba3c'}
},
'Hilbert Transform (Trend vs Cycle)': {
'HT_TRENDMODE': {'color': '#6f1a7b'}
}
}
}
Expand Down