-
Notifications
You must be signed in to change notification settings - Fork 77
/
BB_RPB_TSL_SMA_Tranz_1_5_2_MAIN (8).py
3971 lines (3349 loc) · 225 KB
/
BB_RPB_TSL_SMA_Tranz_1_5_2_MAIN (8).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# --- Do not remove these libs ---
import pandas_ta as pta
import copy
import logging
import pathlib
import rapidjson
import freqtrade.vendor.qtpylib.indicators as qtpylib
import numpy as np
import talib.abstract as ta
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import merge_informative_pair, timeframe_to_minutes
from freqtrade.exchange import timeframe_to_prev_date
from pandas import DataFrame, Series, concat, DatetimeIndex, merge
from functools import reduce
import math
from random import shuffle
from typing import Dict, List
import technical.indicators as ftt
from technical.util import resample_to_interval
from freqtrade.persistence import Trade
from datetime import datetime, timedelta, timezone
from technical.util import resample_to_interval, resampled_merge
from technical.indicators import RMI, zema, VIDYA, ichimoku
from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter, IStrategy, IntParameter)
from skopt.space import Dimension, Integer, Real
import time
from finta import TA as fta
log = logging.getLogger(__name__)
# --------------------------------
def ha_typical_price(bars):
res = (bars['ha_high'] + bars['ha_low'] + bars['ha_close']) / 3
return Series(index=bars.index, data=res)
def VWAPB(dataframe, window_size=20, num_of_std=1):
df = dataframe.copy()
df['vwap'] = qtpylib.rolling_vwap(df,window=window_size)
rolling_std = df['vwap'].rolling(window=window_size).std()
df['vwap_low'] = df['vwap'] - (rolling_std * num_of_std)
df['vwap_high'] = df['vwap'] + (rolling_std * num_of_std)
return df['vwap_low'], df['vwap'], df['vwap_high']
# Volume Weighted Moving Average
def vwma(dataframe: DataFrame, length: int = 10):
"""Indicator: Volume Weighted Moving Average (VWMA)"""
# Calculate Result
pv = dataframe['close'] * dataframe['volume']
vwma = Series(ta.SMA(pv, timeperiod=length) / ta.SMA(dataframe['volume'], timeperiod=length))
return vwma
# Modified Elder Ray Index
def moderi(dataframe: DataFrame, len_slow_ma: int = 32) -> Series:
slow_ma = Series(ta.EMA(vwma(dataframe, length=len_slow_ma), timeperiod=len_slow_ma))
return slow_ma >= slow_ma.shift(1) # we just need true & false for ERI trend
def EWO(dataframe, ema_length=5, ema2_length=35):
df = dataframe.copy()
ema1 = ta.EMA(df, timeperiod=ema_length)
ema2 = ta.EMA(df, timeperiod=ema2_length)
emadif = (ema1 - ema2) / df['low'] * 100
return emadif
def SROC(dataframe, roclen=21, emalen=13, smooth=21):
df = dataframe.copy()
roc = ta.ROC(df, timeperiod=roclen)
ema = ta.EMA(df, timeperiod=emalen)
sroc = ta.ROC(ema, timeperiod=smooth)
return sroc
def range_percent_change(dataframe: DataFrame, method, length: int) -> float:
"""
Rolling Percentage Change Maximum across interval.
:param dataframe: DataFrame The original OHLC dataframe
:param method: High to Low / Open to Close
:param length: int The length to look back
"""
if method == 'HL':
return (dataframe['high'].rolling(length).max() - dataframe['low'].rolling(length).min()) / dataframe['low'].rolling(length).min()
elif method == 'OC':
return (dataframe['open'].rolling(length).max() - dataframe['close'].rolling(length).min()) / dataframe['close'].rolling(length).min()
else:
raise ValueError(f"Method {method} not defined!")
# Williams %R
def williams_r(dataframe: DataFrame, period: int = 14) -> Series:
"""Williams %R, or just %R, is a technical analysis oscillator showing the current closing price in relation to the high and low
of the past N days (for a given N). It was developed by a publisher and promoter of trading materials, Larry Williams.
Its purpose is to tell whether a stock or commodity market is trading near the high or the low, or somewhere in between,
of its recent trading range.
The oscillator is on a negative scale, from -100 (lowest) up to 0 (highest).
"""
highest_high = dataframe["high"].rolling(center=False, window=period).max()
lowest_low = dataframe["low"].rolling(center=False, window=period).min()
WR = Series(
(highest_high - dataframe["close"]) / (highest_high - lowest_low),
name=f"{period} Williams %R",
)
return WR * -100
# Chaikin Money Flow
def chaikin_money_flow(dataframe, n=20, fillna=False) -> Series:
"""Chaikin Money Flow (CMF)
It measures the amount of Money Flow Volume over a specific period.
http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:chaikin_money_flow_cmf
Args:
dataframe(pandas.Dataframe): dataframe containing ohlcv
n(int): n period.
fillna(bool): if fill nan values.
Returns:
pandas.Series: New feature generated.
"""
mfv = ((dataframe['close'] - dataframe['low']) - (dataframe['high'] - dataframe['close'])) / (dataframe['high'] - dataframe['low'])
mfv = mfv.fillna(0.0) # float division by zero
mfv *= dataframe['volume']
cmf = (mfv.rolling(n, min_periods=0).sum()
/ dataframe['volume'].rolling(n, min_periods=0).sum())
if fillna:
cmf = cmf.replace([np.inf, -np.inf], np.nan).fillna(0)
return Series(cmf, name='cmf')
def HA(dataframe, smoothing=None):
df = dataframe.copy()
df['HA_Close']=(df['open'] + df['high'] + df['low'] + df['close'])/4
df.reset_index(inplace=True)
ha_open = [ (df['open'][0] + df['close'][0]) / 2 ]
[ ha_open.append((ha_open[i] + df['HA_Close'].values[i]) / 2) for i in range(0, len(df)-1) ]
df['HA_Open'] = ha_open
df.set_index('index', inplace=True)
df['HA_High']=df[['HA_Open','HA_Close','high']].max(axis=1)
df['HA_Low']=df[['HA_Open','HA_Close','low']].min(axis=1)
if smoothing is not None:
sml = abs(int(smoothing))
if sml > 0:
df['Smooth_HA_O']=ta.EMA(df['HA_Open'], sml)
df['Smooth_HA_C']=ta.EMA(df['HA_Close'], sml)
df['Smooth_HA_H']=ta.EMA(df['HA_High'], sml)
df['Smooth_HA_L']=ta.EMA(df['HA_Low'], sml)
return df
def pump_warning(dataframe, perc=15):
df = dataframe.copy()
df["change"] = df["high"] - df["low"]
df["test1"] = (df["close"] > df["open"])
df["test2"] = ((df["change"]/df["low"]) > (perc/100))
df["result"] = (df["test1"] & df["test2"]).astype('int')
return df['result']
def pump_warning2(dataframe, params):
pct_change_timeframe=8
pct_change_max=0.15
pct_change_min=-0.15
pct_change_short_timeframe=8
pct_change_short_max=0.08
pct_change_short_min=-0.08
ispumping=0.4
islongpumping=0.48
isshortpumping=0.10
ispumping_rolling=20
islongpumping_rolling=30
isshortpumping_rolling=10
recentispumping_rolling=300
if 'pct_change_timeframe' in params:
pct_change_timeframe = params['pct_change_timeframe']
if 'pct_change_max' in params:
pct_change_max = params['pct_change_max']
if 'pct_change_min' in params:
pct_change_min = params['pct_change_min']
if 'pct_change_short_timeframe' in params:
pct_change_short_timeframe = params['pct_change_short_timeframe']
if 'pct_change_short_max' in params:
pct_change_short_max = params['pct_change_short_max']
if 'pct_change_short_min' in params:
pct_change_short_min = params['pct_change_short_min']
if 'ispumping' in params:
ispumping = params['ispumping']
if 'islongpumping' in params:
islongpumping = params['islongpumping']
if 'isshortpumping' in params:
isshortpumping = params['isshortpumping']
if 'ispumping_rolling' in params:
ispumping_rolling = params['ispumping_rolling']
if 'isshortpumping_rolling' in params:
isshortpumping_rolling = params['isshortpumping_rolling']
if 'recentispumping_rolling' in params:
recentispumping_rolling = params['recentispumping_rolling']
df = dataframe.copy()
df['pct_change'] = df['close'].pct_change(periods=pct_change_timeframe)
df['pct_change_int'] = ((df['pct_change'] > pct_change_max).astype('int') | (df['pct_change'] < pct_change_min).astype('int'))
df['pct_change_short'] = df['close'].pct_change(periods=pct_change_short_timeframe)
df['pct_change_int_short'] = ((df['pct_change_short'] > pct_change_short_max).astype('int') | (df['pct_change_short'] < pct_change_short_min).astype('int'))
df['ispumping'] = ((df['pct_change_int'].rolling(ispumping_rolling).sum() >= ispumping)).astype('int')
df['islongpumping'] = ((df['pct_change_int'].rolling(islongpumping_rolling).sum() >= islongpumping)).astype('int')
df['isshortpumping'] = ((df['pct_change_int_short'].rolling(isshortpumping_rolling).sum() >= isshortpumping)).astype('int')
df['recentispumping'] = (df['ispumping'].rolling(recentispumping_rolling).max() > 0) | (df['islongpumping'].rolling(recentispumping_rolling).max() > 0) | (df['isshortpumping'].rolling(recentispumping_rolling).max() > 0)
return df['recentispumping']
def dump_warning(dataframe, buy_threshold):
df_past = dataframe.copy().shift(1) # Get recent BTC info
# 5m dump protection
df_past_source = (df_past['open'] + df_past['close'] + df_past['high'] + df_past['low']) / 4 # Get BTC price
df_threshold = df_past_source * buy_threshold # BTC dump n% in 5 min
df_past_delta = df_past['close'].shift(1) - df_past['close'] # should be positive if dump
df_diff = df_threshold - df_past_delta # Need be larger than 0
dataframe['pair_threshold'] = df_threshold
dataframe['pair_diff'] = df_diff
# 1d dump protection
df_past_1d = dataframe.copy().shift(288)
df_past_source_1d = (df_past_1d['open'] + df_past_1d['close'] + df_past_1d['high'] + df_past_1d['low']) / 4
dataframe['pair_5m'] = df_past_source
dataframe['pair_1d'] = df_past_source_1d
dataframe['pair_5m_1d_diff'] = df_past_source - df_past_source_1d
return dataframe
# Elliot Wave Oscillator
def ewo(dataframe, sma1_length=5, sma2_length=35):
sma1 = ta.EMA(dataframe, timeperiod=sma1_length)
sma2 = ta.EMA(dataframe, timeperiod=sma2_length)
smadif = (sma1 - sma2) / dataframe['close'] * 100
return smadif
# Exponential moving average of a volume weighted simple moving average
def ema_vwma_osc(dataframe, len_slow_ma):
slow_ema = Series(ta.EMA(vwma(dataframe, len_slow_ma), len_slow_ma))
return ((slow_ema - slow_ema.shift(1)) / slow_ema.shift(1)) * 100
def pivot_points(dataframe: DataFrame, mode = 'fibonacci') -> Series:
hlc3_pivot = (dataframe['high'] + dataframe['low'] + dataframe['close']).shift(1) / 3
hl_range = (dataframe['high'] - dataframe['low']).shift(1)
if mode == 'simple':
res1 = hlc3_pivot * 2 - dataframe['low'].shift(1)
sup1 = hlc3_pivot * 2 - dataframe['high'].shift(1)
res2 = hlc3_pivot + (dataframe['high'] - dataframe['low']).shift()
sup2 = hlc3_pivot - (dataframe['high'] - dataframe['low']).shift()
res3 = hlc3_pivot * 2 + (dataframe['high'] - 2 * dataframe['low']).shift()
sup3 = hlc3_pivot * 2 - (2 * dataframe['high'] - dataframe['low']).shift()
elif mode == 'fibonacci':
res1 = hlc3_pivot + 0.382 * hl_range
sup1 = hlc3_pivot - 0.382 * hl_range
res2 = hlc3_pivot + 0.618 * hl_range
sup2 = hlc3_pivot - 0.618 * hl_range
res3 = hlc3_pivot + 1 * hl_range
sup3 = hlc3_pivot - 1 * hl_range
return hlc3_pivot, res1, res2, res3, sup1, sup2, sup3
def heikin_ashi(dataframe, smooth_inputs = False, smooth_outputs = False, length = 10):
df = dataframe[['open','close','high','low']].copy().fillna(0)
if smooth_inputs:
df['open_s'] = ta.EMA(df['open'], timeframe = length)
df['high_s'] = ta.EMA(df['high'], timeframe = length)
df['low_s'] = ta.EMA(df['low'], timeframe = length)
df['close_s'] = ta.EMA(df['close'],timeframe = length)
open_ha = (df['open_s'].shift(1) + df['close_s'].shift(1)) / 2
high_ha = df.loc[:, ['high_s', 'open_s', 'close_s']].max(axis=1)
low_ha = df.loc[:, ['low_s', 'open_s', 'close_s']].min(axis=1)
close_ha = (df['open_s'] + df['high_s'] + df['low_s'] + df['close_s'])/4
else:
open_ha = (df['open'].shift(1) + df['close'].shift(1)) / 2
high_ha = df.loc[:, ['high', 'open', 'close']].max(axis=1)
low_ha = df.loc[:, ['low', 'open', 'close']].min(axis=1)
close_ha = (df['open'] + df['high'] + df['low'] + df['close'])/4
open_ha = open_ha.fillna(0)
high_ha = high_ha.fillna(0)
low_ha = low_ha.fillna(0)
close_ha = close_ha.fillna(0)
if smooth_outputs:
open_sha = ta.EMA(open_ha, timeframe = length)
high_sha = ta.EMA(high_ha, timeframe = length)
low_sha = ta.EMA(low_ha, timeframe = length)
close_sha = ta.EMA(close_ha, timeframe = length)
return open_sha, close_sha, low_sha
else:
return open_ha, close_ha, low_ha
# PMAX
def pmax(df, period, multiplier, length, MAtype, src):
period = int(period)
multiplier = int(multiplier)
length = int(length)
MAtype = int(MAtype)
src = int(src)
mavalue = f'MA_{MAtype}_{length}'
atr = f'ATR_{period}'
pm = f'pm_{period}_{multiplier}_{length}_{MAtype}'
pmx = f'pmX_{period}_{multiplier}_{length}_{MAtype}'
# MAtype==1 --> EMA
# MAtype==2 --> DEMA
# MAtype==3 --> T3
# MAtype==4 --> SMA
# MAtype==5 --> VIDYA
# MAtype==6 --> TEMA
# MAtype==7 --> WMA
# MAtype==8 --> VWMA
# MAtype==9 --> zema
if src == 1:
masrc = df["close"]
elif src == 2:
masrc = (df["high"] + df["low"]) / 2
elif src == 3:
masrc = (df["high"] + df["low"] + df["close"] + df["open"]) / 4
if MAtype == 1:
mavalue = ta.EMA(masrc, timeperiod=length)
elif MAtype == 2:
mavalue = ta.DEMA(masrc, timeperiod=length)
elif MAtype == 3:
mavalue = ta.T3(masrc, timeperiod=length)
elif MAtype == 4:
mavalue = ta.SMA(masrc, timeperiod=length)
elif MAtype == 5:
mavalue = VIDYA(df, length=length)
elif MAtype == 6:
mavalue = ta.TEMA(masrc, timeperiod=length)
elif MAtype == 7:
mavalue = ta.WMA(df, timeperiod=length)
elif MAtype == 8:
mavalue = vwma(df, length)
elif MAtype == 9:
mavalue = zema(df, period=length)
df[atr] = ta.ATR(df, timeperiod=period)
df['basic_ub'] = mavalue + ((multiplier/10) * df[atr])
df['basic_lb'] = mavalue - ((multiplier/10) * df[atr])
basic_ub = df['basic_ub'].values
final_ub = np.full(len(df), 0.00)
basic_lb = df['basic_lb'].values
final_lb = np.full(len(df), 0.00)
for i in range(period, len(df)):
final_ub[i] = basic_ub[i] if (
basic_ub[i] < final_ub[i - 1]
or mavalue[i - 1] > final_ub[i - 1]) else final_ub[i - 1]
final_lb[i] = basic_lb[i] if (
basic_lb[i] > final_lb[i - 1]
or mavalue[i - 1] < final_lb[i - 1]) else final_lb[i - 1]
df['final_ub'] = final_ub
df['final_lb'] = final_lb
pm_arr = np.full(len(df), 0.00)
for i in range(period, len(df)):
pm_arr[i] = (
final_ub[i] if (pm_arr[i - 1] == final_ub[i - 1]
and mavalue[i] <= final_ub[i])
else final_lb[i] if (
pm_arr[i - 1] == final_ub[i - 1]
and mavalue[i] > final_ub[i]) else final_lb[i]
if (pm_arr[i - 1] == final_lb[i - 1]
and mavalue[i] >= final_lb[i]) else final_ub[i]
if (pm_arr[i - 1] == final_lb[i - 1]
and mavalue[i] < final_lb[i]) else 0.00)
pm = Series(pm_arr)
# Mark the trend direction up/down
pmx = np.where((pm_arr > 0.00), np.where((mavalue < pm_arr), 'down', 'up'), np.NaN)
return pm, pmx
# Mom DIV
def momdiv(dataframe: DataFrame, mom_length: int = 10, bb_length: int = 20, bb_dev: float = 2.0, lookback: int = 30) -> DataFrame:
mom: Series = ta.MOM(dataframe, timeperiod=mom_length)
upperband, middleband, lowerband = ta.BBANDS(mom, timeperiod=bb_length, nbdevup=bb_dev, nbdevdn=bb_dev, matype=0)
buy = qtpylib.crossed_below(mom, lowerband)
sell = qtpylib.crossed_above(mom, upperband)
hh = dataframe['high'].rolling(lookback).max()
ll = dataframe['low'].rolling(lookback).min()
coh = dataframe['high'] >= hh
col = dataframe['low'] <= ll
df = DataFrame({
"momdiv_mom": mom,
"momdiv_upperb": upperband,
"momdiv_lowerb": lowerband,
"momdiv_buy": buy,
"momdiv_sell": sell,
"momdiv_coh": coh,
"momdiv_col": col,
}, index=dataframe['close'].index)
return df
def pct_change(a, b):
return (b - a) / a
def T3(dataframe, length=5):
"""
T3 Average by HPotter on Tradingview
https://www.tradingview.com/script/qzoC9H1I-T3-Average/
"""
df = dataframe.copy()
df['xe1'] = ta.EMA(df['close'], timeperiod=length)
df['xe2'] = ta.EMA(df['xe1'], timeperiod=length)
df['xe3'] = ta.EMA(df['xe2'], timeperiod=length)
df['xe4'] = ta.EMA(df['xe3'], timeperiod=length)
df['xe5'] = ta.EMA(df['xe4'], timeperiod=length)
df['xe6'] = ta.EMA(df['xe5'], timeperiod=length)
b = 0.7
c1 = -b * b * b
c2 = 3 * b * b + 3 * b * b * b
c3 = -6 * b * b - 3 * b - 3 * b * b * b
c4 = 1 + 3 * b + b * b * b + 3 * b * b
df['T3Average'] = c1 * df['xe6'] + c2 * df['xe5'] + c3 * df['xe4'] + c4 * df['xe3']
return df['T3Average']
class BB_RPB_TSL_SMA_Tranz(IStrategy):
'''
BB_RPB_TSL
@author jilv220
Simple bollinger brand strategy inspired by this blog ( https://hacks-for-life.blogspot.com/2020/12/freqtrade-notes.html )
RPB, which stands for Real Pull Back, taken from ( https://github.com/GeorgeMurAlkh/freqtrade-stuff/blob/main/user_data/strategies/TheRealPullbackV2.py )
The trailing custom stoploss taken from BigZ04_TSL from Perkmeister ( modded by ilya )
I modified it to better suit my taste and added Hyperopt for this strategy.
'''
# (1) sell rework
##########################################################################
# Hyperopt result area
DATESTAMP = 0
SELLMA = 1
SELL_TRIGGER=2
# buy space
buy_params = {
"buy_btc_safe": -250,
"buy_btc_safe_1d": -0.020,
##
"base_nb_candles_buy3": 20,
"ewo_high3": 4.299,
"ewo_high_3": 8.492,
"ewo_low3": -8.476,
"low_offset3": 0.984,
"low_offset_33": 0.901,
"lookback_candles3": 7,
"profit_threshold3": 1.036,
"rsi_buy3": 80,
"rsi_fast_buy3": 27,
##
"max_slip": 0.983,
##
"buy_bb_width_1h": 0.954,
"buy_roc_1h": 86,
##
"buy_threshold": 0.003,
"buy_bb_factor": 0.999,
#
"buy_bb_delta": 0.025,
"buy_bb_width": 0.095,
##
"buy_cci": -116,
"buy_cci_length": 25,
"buy_rmi": 49,
"buy_rmi_length": 17,
"buy_srsi_fk": 32,
##
"buy_closedelta": 17.922,
"buy_ema_diff": 0.026,
##
"buy_ema_high": 0.968,
"buy_ema_low": 0.935,
"buy_ewo": -5.001,
"buy_rsi": 23,
"buy_rsi_fast": 44,
##
"base_nb_candles_buy_trima": 15,
"base_nb_candles_buy_trima2": 38,
"low_offset_trima": 0.959,
"low_offset_trima2": 0.949,
"base_nb_candles_buy_hma": 70,
"base_nb_candles_buy_hma2": 12,
"low_offset_hma": 0.948,
"low_offset_hma2": 0.941,
#
"base_nb_candles_buy_zema": 25,
"base_nb_candles_buy_zema2": 53,
"low_offset_zema": 0.958,
"low_offset_zema2": 0.961,
#
"base_nb_candles_buy_ema": 9,
"base_nb_candles_buy_ema2": 75,
"low_offset_ema": 1.067,
"low_offset_ema2": 0.973,
"buy_closedelta_local_dip": 12.044,
"buy_ema_diff_local_dip": 0.024,
"buy_ema_high_local_dip": 1.014,
"buy_rsi_local_dip": 21,
##
"ewo_high": 2.615,
"ewo_high2": 2.188,
"ewo_low": -19.632,
"ewo_low2": -19.955,
"rsi_buy": 60,
"rsi_buy2": 45,
#
"pump_protection_01_pct_change_timeframe": 8,
"pump_protection_01_pct_change_max": 0.15,
"pump_protection_01_pct_change_min": -0.15,
#
"pump_protection_01_pct_change_short_timeframe": 8,
"pump_protection_01_pct_change_short_max": 0.1,
"pump_protection_01_pct_change_short_min": -0.1,
#
"pump_protection_01_ispumping": 0.2,
"pump_protection_01_islongpumping": 0.24,
"pump_protection_01_isshortpumping": 0.12,
#
"buy_r_deadfish_bb_factor": 1.014,
"buy_r_deadfish_bb_width": 0.299,
"buy_r_deadfish_ema": 1.054,
"buy_r_deadfish_volume_factor": 1.59,
"buy_r_deadfish_cti": -0.115,
"buy_r_deadfish_r14": -44.34,
##
"buy_ema_high_2": 1.04116,
"buy_ema_low_2": 0.97463,
"buy_ewo_high_2": 5.249,
"buy_rsi_ewo_2": 35,
"buy_rsi_fast_ewo_2": 45,
##
"lambo2_ema_14_factor": 0.981,
"lambo2_enabled": True,
"lambo2_rsi_14_limit": 39,
"lambo2_rsi_4_limit": 44,
##
"buy_clucha_bbdelta_close": 0.049,
"buy_clucha_bbdelta_tail": 1.146,
"buy_clucha_close_bblower": 0.018,
"buy_clucha_closedelta_close": 0.017,
"buy_clucha_rocr_1h": 0.526,
##
"buy_adx": 13,
"buy_cofi_r14": -85.016,
"buy_cofi_cti": -0.892,
"buy_ema_cofi": 1.147,
"buy_ewo_high": 8.594,
"buy_fastd": 28,
"buy_fastk": 39,
##
"buy_gumbo_ema": 1.121,
"buy_gumbo_ewo_low": -9.442,
"buy_gumbo_cti": -0.374,
"buy_gumbo_r14": -51.971,
##
"buy_sqzmom_ema": 0.981,
"buy_sqzmom_ewo": -3.966,
"buy_sqzmom_r14": -45.068,
##
"buy_nfix_49_cti": -0.105,
"buy_nfix_49_r14": -81.827,
##
"base_nb_candles_ema_sell": 5,
"high_offset_sell_ema": 0.994,
#
"base_nb_candles_buy": 8,
"ewo_high": 4.13,
"ewo_high_2": 4.477,
"ewo_low": -19.076,
"lookback_candles": 27,
"low_offset": 0.988,
"low_offset_2": 0.974,
"profit_threshold": 1.049,
"rsi_buy": 72,
"rsi_fast_buy": 40,
#ADIX
"ewo_high_adix":6.735,
"ewo_low_adix": -18.691,
"ewo_low2_adix": -11.353,
"ewo_high2_adix": 4.506,
"rsi_buy_adix":30,
"rsi_buy2_adix": 55,
}
protection_params = {
"low_profit_lookback": 48,
"low_profit_min_req": 0.04,
"low_profit_stop_duration": 14,
"cooldown_lookback": 2, # value loaded from strategy
}
#############################################################
sell_params = {
##
"sell_cmf": -0.046,
"sell_ema": 0.988,
"sell_ema_close_delta": 0.022,
##
"sell_deadfish_profit": -0.063,
"sell_deadfish_bb_factor": 0.954,
"sell_deadfish_bb_width": 0.043,
"sell_deadfish_volume_factor": 2.37,
##
"sell_cti_r_cti": 0.844,
"sell_cti_r_r": -19.99,
#
"base_nb_candles_sell": 8,
"high_offset": 1.012,
"high_offset_2": 1.431,
#############
"base_nb_candles_sell3": 20,
"high_offset3": 1.01,
"high_offset_33": 1.142,
# Enable/Disable conditions
"sell_condition_1_enable": True,
"sell_condition_2_enable": True,
"sell_condition_3_enable": True,
"sell_condition_4_enable": True,
"sell_condition_5_enable": True,
"sell_condition_6_enable": True,
"sell_condition_7_enable": True,
"sell_condition_8_enable": True,
#############
}
sell_condition_2_enable = CategoricalParameter([True, False], default=True, space='sell', optimize=False, load=True)
sell_condition_3_enable = CategoricalParameter([True, False], default=True, space='sell', optimize=False, load=True)
sell_condition_4_enable = CategoricalParameter([True, False], default=True, space='sell', optimize=False, load=True)
sell_condition_5_enable = CategoricalParameter([True, False], default=True, space='sell', optimize=False, load=True)
sell_condition_6_enable = CategoricalParameter([True, False], default=True, space='sell', optimize=False, load=True)
sell_condition_7_enable = CategoricalParameter([True, False], default=True, space='sell', optimize=False, load=True)
sell_condition_8_enable = CategoricalParameter([True, False], default=True, space='sell', optimize=False, load=True)
# Protection hyperspace params:
class HyperOpt:
@staticmethod
def generate_roi_table(params: dict):
"""
Generate the ROI table that will be used by Hyperopt
This implementation generates the default legacy Freqtrade ROI tables.
Change it if you need different number of steps in the generated
ROI tables or other structure of the ROI tables.
Please keep it aligned with parameters in the 'roi' optimization
hyperspace defined by the roi_space method.
"""
roi_table = {}
roi_table[0] = 0.05
roi_table[params['roi_t6']] = 0.04
roi_table[params['roi_t5']] = 0.03
roi_table[params['roi_t4']] = 0.02
roi_table[params['roi_t3']] = 0.01
roi_table[params['roi_t2']] = 0.0001
roi_table[params['roi_t1']] = -10
return roi_table
@staticmethod
def roi_space() -> List[Dimension]:
"""
Values to search for each ROI steps
Override it if you need some different ranges for the parameters in the
'roi' optimization hyperspace.
Please keep it aligned with the implementation of the
generate_roi_table method.
"""
return [
Integer(240, 720, name='roi_t1'),
Integer(120, 240, name='roi_t2'),
Integer(90, 120, name='roi_t3'),
Integer(60, 90, name='roi_t4'),
Integer(30, 60, name='roi_t5'),
Integer(1, 30, name='roi_t6'),
]
minimal_roi = {
"0": 0.10347601757573865,
"3": 0.050495605759981035,
"5": 0.03350898081823659,
"61": 0.0275218557571848,
"292": 0.005185372158403069,
"399": 0,
}
# Optimal timeframe for the strategy
timeframe = '5m'
inf_15m = '15m'
inf_1h = '1h'
# Run "populate_indicators()" only for new candle.
process_only_new_candles = True
# Disabled
stoploss = -0.13
process_only_new_candles = True
startup_candle_count = 200
use_custom_stoploss = False
slippage_protection = {
'retries': 3,
'max_slippage': -0.02
}
protections = [
{
"method": "LowProfitPairs",
"lookback_period_candles": 60,
"trade_limit": 1,
"stop_duration": 60,
"required_profit": -0.05
},
{
"method": "MaxDrawdown",
"lookback_period_candles": 24,
"trade_limit": 1,
"stop_duration_candles": 12,
"max_allowed_drawdown": 0.2
},
]
############################################################################
####ADIX
ewo_high_adix = DecimalParameter( 2.0, 12.0, default=buy_params['ewo_high_adix'], space='buy', optimize=True)
ewo_high2_adix = DecimalParameter( 2.0, 12.0, default=buy_params['ewo_high2_adix'], space='buy', optimize=True)
ewo_high2_adix
ewo_low_adix = DecimalParameter( 2.0, 12.0, default=buy_params['ewo_low_adix'], space='buy', optimize=True)
ewo_low2_adix = DecimalParameter( 2.0, 12.0, default=buy_params['ewo_low2_adix'], space='buy', optimize=True)
rsi_buy_adix = IntParameter(30, 70, default=buy_params['rsi_buy_adix'], space='buy', optimize=False)
rsi_buy2_adix = IntParameter(30, 70, default=buy_params['rsi_buy2_adix'], space='buy', optimize=False)
##LAMBO
lambo2_ema_14_factor = DecimalParameter(0.9, 0.99, default=buy_params['lambo2_ema_14_factor'], space='buy', optimize=True)
lambo2_rsi_4_limit = IntParameter(2, 50, default=buy_params['lambo2_rsi_4_limit'], space='buy', optimize=True)
lambo2_rsi_14_limit = IntParameter(2, 50, default=buy_params['lambo2_rsi_14_limit'], space='buy', optimize=True)
# SMAOffset
base_nb_candles_buy = IntParameter(2, 20, default=buy_params['base_nb_candles_buy'], space='buy', optimize=True)
base_nb_candles_sell = IntParameter(2, 25, default=sell_params['base_nb_candles_sell'], space='sell', optimize=True)
low_offset = DecimalParameter(0.9, 0.99, default=buy_params['low_offset'], space='buy', optimize=True)
low_offset_2 = DecimalParameter(0.9, 0.99, default=buy_params['low_offset_2'], space='buy', optimize=True)
high_offset = DecimalParameter(0.95, 1.1, default=sell_params['high_offset'], space='sell', optimize=True)
high_offset_2 = DecimalParameter(0.99, 1.5, default=sell_params['high_offset_2'], space='sell', optimize=True)
# Multi Offset
optimize_buy_ema = False
base_nb_candles_buy_ema = IntParameter(5, 80, default=20, space='buy', optimize=optimize_buy_ema)
low_offset_ema = DecimalParameter(0.9, 1.1, default=0.958, space='buy', optimize=optimize_buy_ema)
base_nb_candles_buy_ema2 = IntParameter(5, 80, default=20, space='buy', optimize=optimize_buy_ema)
low_offset_ema2 = DecimalParameter(0.9, 1.1, default=0.958, space='buy', optimize=optimize_buy_ema)
# Protection
fast_ewo = 50
slow_ewo = 200
lookback_candles = IntParameter(1, 36, default=buy_params['lookback_candles'], space='buy', optimize=True)
profit_threshold = DecimalParameter(0.99, 1.05, default=buy_params['profit_threshold'], space='buy', optimize=True)
ewo_low = DecimalParameter(-20.0, -8.0, default=buy_params['ewo_low'], space='buy', optimize=True)
ewo_high = DecimalParameter( 2.0, 12.0, default=buy_params['ewo_high'], space='buy', optimize=True)
ewo_low2 = DecimalParameter(-20.0, -8.0, default=buy_params['ewo_low2'], space='buy', optimize=True)
ewo_high2 = DecimalParameter(2.0, 12.0, default=buy_params['ewo_high2'], space='buy', optimize=True)
ewo_high_2 = DecimalParameter( -6.0, 12.0, default=buy_params['ewo_high_2'], space='buy', optimize=True)
rsi_buy = IntParameter(10, 80, default=buy_params['rsi_buy'], space='buy', optimize=True)
rsi_buy2 = IntParameter(30, 70, default=buy_params['rsi_buy2'], space='buy', optimize=True)
rsi_fast_buy = IntParameter(10, 50, default=buy_params['rsi_fast_buy'], space='buy', optimize=True)
## Buy params
max_change_pump = 35
is_optimize_dip = False
buy_rmi = IntParameter(30, 50, default=35, optimize= is_optimize_dip)
buy_cci = IntParameter(-135, -90, default=-133, optimize= is_optimize_dip)
buy_srsi_fk = IntParameter(30, 50, default=25, optimize= is_optimize_dip)
buy_cci_length = IntParameter(25, 45, default=25, optimize = is_optimize_dip)
buy_rmi_length = IntParameter(8, 20, default=8, optimize = is_optimize_dip)
is_optimize_break = False
buy_bb_width = DecimalParameter(0.065, 0.135, default=0.095, optimize = is_optimize_break)
buy_bb_delta = DecimalParameter(0.018, 0.035, default=0.025, optimize = is_optimize_break)
is_optimize_local_uptrend = False
buy_ema_diff = DecimalParameter(0.022, 0.027, default=0.025, optimize = is_optimize_local_uptrend)
buy_bb_factor = DecimalParameter(0.990, 0.999, default=0.995, optimize = False)
buy_closedelta = DecimalParameter(12.0, 18.0, default=15.0, optimize = is_optimize_local_uptrend)
is_optimize_local_dip = False
buy_ema_diff_local_dip = DecimalParameter(0.022, 0.027, default=0.025, optimize = is_optimize_local_dip)
buy_ema_high_local_dip = DecimalParameter(0.90, 1.2, default=0.942 , optimize = is_optimize_local_dip)
buy_closedelta_local_dip = DecimalParameter(12.0, 18.0, default=15.0, optimize = is_optimize_local_dip)
buy_rsi_local_dip = IntParameter(15, 45, default=28, optimize = is_optimize_local_dip)
buy_crsi_local_dip = IntParameter(10, 18, default=10, optimize = False)
is_optimize_ewo = False
buy_rsi_fast = IntParameter(35, 50, default=45, optimize = is_optimize_ewo)
buy_rsi = IntParameter(15, 35, default=35, optimize = is_optimize_ewo)
buy_ewo = DecimalParameter(-6.0, 5, default=-5.585, optimize = is_optimize_ewo)
buy_ema_low = DecimalParameter(0.9, 0.99, default=0.942 , optimize = is_optimize_ewo)
buy_ema_high = DecimalParameter(0.95, 1.2, default=1.084 , optimize = is_optimize_ewo)
is_optimize_r_deadfish = False
buy_r_deadfish_ema = DecimalParameter(0.90, 1.2, default=1.087 , optimize = is_optimize_r_deadfish)
buy_r_deadfish_bb_width = DecimalParameter(0.03, 0.75, default=0.05 , optimize = is_optimize_r_deadfish)
buy_r_deadfish_bb_factor = DecimalParameter(0.90, 1.2, default=1.0 , optimize = is_optimize_r_deadfish)
buy_r_deadfish_volume_factor = DecimalParameter(1, 2.5, default=1.0 , optimize = is_optimize_r_deadfish)
is_optimize_r_deadfish_protection = False
buy_r_deadfish_cti = DecimalParameter(-0.6, -0.0, default=-0.5 , optimize = is_optimize_r_deadfish_protection)
buy_r_deadfish_r14 = DecimalParameter(-60, -44, default=-60 , optimize = is_optimize_r_deadfish_protection)
is_optimize_clucha = False
buy_clucha_bbdelta_close = DecimalParameter(0.01,0.05, default=0.02206, optimize = is_optimize_clucha)
buy_clucha_bbdelta_tail = DecimalParameter(0.7, 1.2, default=1.02515, optimize = is_optimize_clucha)
buy_clucha_closedelta_close = DecimalParameter(0.001, 0.05, default=0.04401, optimize = is_optimize_clucha)
buy_clucha_rocr_1h = DecimalParameter(0.1, 1.0, default=0.47782, optimize = is_optimize_clucha)
is_optimize_cofi = False
buy_ema_cofi = DecimalParameter(0.94, 1.2, default=0.97 , optimize = is_optimize_cofi)
buy_fastk = IntParameter(0, 40, default=20, optimize = is_optimize_cofi)
buy_fastd = IntParameter(0, 40, default=20, optimize = is_optimize_cofi)
buy_adx = IntParameter(0, 30, default=30, optimize = is_optimize_cofi)
buy_ewo_high = DecimalParameter(2, 12, default=3.553, optimize = is_optimize_cofi)
is_optimize_cofi_protection = False
buy_cofi_cti = DecimalParameter(-0.9, -0.0, default=-0.5 , optimize = is_optimize_cofi_protection)
buy_cofi_r14 = DecimalParameter(-100, -44, default=-60 , optimize = is_optimize_cofi_protection)
is_optimize_gumbo = False
buy_gumbo_ema = DecimalParameter(0.9, 1.2, default=0.97 , optimize = is_optimize_gumbo)
buy_gumbo_ewo_low = DecimalParameter(-12.0, 5, default=-5.585, optimize = is_optimize_gumbo)
is_optimize_gumbo_protection = False
buy_gumbo_cti = DecimalParameter(-0.9, -0.0, default=-0.5 , optimize = is_optimize_gumbo_protection)
buy_gumbo_r14 = DecimalParameter(-100, -44, default=-60 , optimize = is_optimize_gumbo_protection)
is_optimize_sqzmom_protection = False
buy_sqzmom_ema = DecimalParameter(0.9, 1.2, default=0.97 , optimize = is_optimize_sqzmom_protection)
buy_sqzmom_ewo = DecimalParameter(-12 , 12, default= 0 , optimize = is_optimize_sqzmom_protection)
buy_sqzmom_r14 = DecimalParameter(-100, -22, default=-50 , optimize = is_optimize_sqzmom_protection)
is_optimize_nfix_39 = True
buy_nfix_39_ema = DecimalParameter(0.9, 1.2, default=0.97 , optimize = is_optimize_nfix_39)
is_optimize_nfix_49_protection = False
buy_nfix_49_cti = DecimalParameter(-0.9, -0.0, default=-0.5 , optimize = is_optimize_nfix_49_protection)
buy_nfix_49_r14 = DecimalParameter(-100, -44, default=-60 , optimize = is_optimize_nfix_49_protection)
is_optimize_btc_safe = False
buy_btc_safe = IntParameter(-300, 50, default=-200, optimize = is_optimize_btc_safe)
buy_btc_safe_1d = DecimalParameter(-0.075, -0.025, default=-0.05, optimize = is_optimize_btc_safe)
buy_threshold = DecimalParameter(0.003, 0.012, default=0.008, optimize = is_optimize_btc_safe)
is_optimize_check = False
buy_roc_1h = IntParameter(-25, 200, default=10, optimize = is_optimize_check)
buy_bb_width_1h = DecimalParameter(0.3, 2.0, default=0.3, optimize = is_optimize_check)
#BB MODDED
is_optimize_ctt15_protection = False
buy_ema_open_mult_15 = DecimalParameter(0.01, 0.03, default=0.024, optimize = is_optimize_ctt15_protection)
buy_ma_offset_15 = DecimalParameter(0.93, 0.99, default=0.958, optimize = is_optimize_ctt15_protection)
buy_rsi_15 = DecimalParameter(20.0, 36.0, default=28.0, optimize = is_optimize_ctt15_protection)
buy_ema_rel_15 = DecimalParameter(0.97, 0.999, default=0.974, optimize = is_optimize_ctt15_protection)
is_optimize_ctt25_protection = False
buy_25_ma_offset = DecimalParameter(0.90, 0.99, default=0.922, optimize = is_optimize_ctt25_protection)
buy_25_rsi_4 = DecimalParameter(26.0, 40.0, default=38.0, optimize = is_optimize_ctt25_protection)
buy_25_cti = DecimalParameter(-0.99, -0.4, default=-0.76, optimize = is_optimize_ctt25_protection)
#NFI 7 SMA
buy_dip_threshold_10_1 = DecimalParameter(0.001, 0.05, default=0.015, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_10_2 = DecimalParameter(0.01, 0.2, default=0.1, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_10_3 = DecimalParameter(0.1, 0.3, default=0.24, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_10_4 = DecimalParameter(0.3, 0.5, default=0.42, space='buy', decimals=3, optimize=False, load=True)
# Strict dips - level 20
buy_dip_threshold_20_1 = DecimalParameter(0.001, 0.05, default=0.016, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_20_2 = DecimalParameter(0.01, 0.2, default=0.11, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_20_3 = DecimalParameter(0.1, 0.4, default=0.26, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_20_4 = DecimalParameter(0.36, 0.56, default=0.44, space='buy', decimals=3, optimize=False, load=True)
# Strict dips - level 30
buy_dip_threshold_30_1 = DecimalParameter(0.001, 0.05, default=0.018, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_30_2 = DecimalParameter(0.01, 0.2, default=0.12, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_30_3 = DecimalParameter(0.1, 0.4, default=0.28, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_30_4 = DecimalParameter(0.36, 0.56, default=0.46, space='buy', decimals=3, optimize=False, load=True)
# Strict dips - level 40
buy_dip_threshold_40_1 = DecimalParameter(0.001, 0.05, default=0.019, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_40_2 = DecimalParameter(0.01, 0.2, default=0.13, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_40_3 = DecimalParameter(0.1, 0.4, default=0.3, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_40_4 = DecimalParameter(0.36, 0.56, default=0.48, space='buy', decimals=3, optimize=False, load=True)
# Normal dips - level 50
buy_dip_threshold_50_1 = DecimalParameter(0.001, 0.05, default=0.02, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_50_2 = DecimalParameter(0.01, 0.2, default=0.14, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_50_3 = DecimalParameter(0.05, 0.4, default=0.32, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_50_4 = DecimalParameter(0.2, 0.5, default=0.5, space='buy', decimals=3, optimize=False, load=True)
# Normal dips - level 60
buy_dip_threshold_60_1 = DecimalParameter(0.001, 0.05, default=0.022, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_60_2 = DecimalParameter(0.1, 0.22, default=0.18, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_60_3 = DecimalParameter(0.2, 0.4, default=0.34, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_60_4 = DecimalParameter(0.4, 0.6, default=0.56, space='buy', decimals=3, optimize=False, load=True)
# Normal dips - level 70
buy_dip_threshold_70_1 = DecimalParameter(0.001, 0.05, default=0.023, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_70_2 = DecimalParameter(0.16, 0.28, default=0.2, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_70_3 = DecimalParameter(0.2, 0.4, default=0.36, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_70_4 = DecimalParameter(0.5, 0.7, default=0.6, space='buy', decimals=3, optimize=False, load=True)
# Normal dips - level 80
buy_dip_threshold_80_1 = DecimalParameter(0.001, 0.05, default=0.024, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_80_2 = DecimalParameter(0.16, 0.28, default=0.22, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_80_3 = DecimalParameter(0.2, 0.4, default=0.38, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_80_4 = DecimalParameter(0.5, 0.7, default=0.66, space='buy', decimals=3, optimize=False, load=True)
# Normal dips - level 70
buy_dip_threshold_90_1 = DecimalParameter(0.001, 0.05, default=0.025, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_90_2 = DecimalParameter(0.16, 0.28, default=0.23, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_90_3 = DecimalParameter(0.3, 0.5, default=0.4, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_90_4 = DecimalParameter(0.6, 0.8, default=0.7, space='buy', decimals=3, optimize=False, load=True)
# Loose dips - level 100
buy_dip_threshold_100_1 = DecimalParameter(0.001, 0.05, default=0.026, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_100_2 = DecimalParameter(0.16, 0.3, default=0.24, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_100_3 = DecimalParameter(0.3, 0.5, default=0.42, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_100_4 = DecimalParameter(0.6, 1.0, default=0.8, space='buy', decimals=3, optimize=False, load=True)
# Loose dips - level 110
buy_dip_threshold_110_1 = DecimalParameter(0.001, 0.05, default=0.027, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_110_2 = DecimalParameter(0.16, 0.3, default=0.26, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_110_3 = DecimalParameter(0.3, 0.5, default=0.44, space='buy', decimals=3, optimize=False, load=True)
buy_dip_threshold_110_4 = DecimalParameter(0.6, 1.0, default=0.84, space='buy', decimals=3, optimize=False, load=True)
# 24 hours - level 10
buy_pump_pull_threshold_10_24 = DecimalParameter(1.5, 3.0, default=2.2, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_10_24 = DecimalParameter(0.4, 1.0, default=0.42, space='buy', decimals=3, optimize=False, load=True)
# 36 hours - level 10
buy_pump_pull_threshold_10_36 = DecimalParameter(1.5, 3.0, default=2.0, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_10_36 = DecimalParameter(0.4, 1.0, default=0.58, space='buy', decimals=3, optimize=False, load=True)
# 48 hours - level 10
buy_pump_pull_threshold_10_48 = DecimalParameter(1.5, 3.0, default=2.0, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_10_48 = DecimalParameter(0.4, 1.0, default=0.8, space='buy', decimals=3, optimize=False, load=True)
# 24 hours - level 20
buy_pump_pull_threshold_20_24 = DecimalParameter(1.5, 3.0, default=2.2, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_20_24 = DecimalParameter(0.4, 1.0, default=0.46, space='buy', decimals=3, optimize=False, load=True)
# 36 hours - level 20
buy_pump_pull_threshold_20_36 = DecimalParameter(1.5, 3.0, default=2.0, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_20_36 = DecimalParameter(0.4, 1.0, default=0.6, space='buy', decimals=3, optimize=False, load=True)
# 48 hours - level 20
buy_pump_pull_threshold_20_48 = DecimalParameter(1.5, 3.0, default=2.0, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_20_48 = DecimalParameter(0.4, 1.0, default=0.81, space='buy', decimals=3, optimize=False, load=True)
# 24 hours - level 30
buy_pump_pull_threshold_30_24 = DecimalParameter(1.5, 3.0, default=2.2, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_30_24 = DecimalParameter(0.4, 1.0, default=0.5, space='buy', decimals=3, optimize=False, load=True)
# 36 hours - level 30
buy_pump_pull_threshold_30_36 = DecimalParameter(1.5, 3.0, default=2.0, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_30_36 = DecimalParameter(0.4, 1.0, default=0.62, space='buy', decimals=3, optimize=False, load=True)
# 48 hours - level 30
buy_pump_pull_threshold_30_48 = DecimalParameter(1.5, 3.0, default=2.0, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_30_48 = DecimalParameter(0.4, 1.0, default=0.82, space='buy', decimals=3, optimize=False, load=True)
# 24 hours - level 40
buy_pump_pull_threshold_40_24 = DecimalParameter(1.5, 3.0, default=2.2, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_40_24 = DecimalParameter(0.4, 1.0, default=0.54, space='buy', decimals=3, optimize=False, load=True)
# 36 hours - level 40
buy_pump_pull_threshold_40_36 = DecimalParameter(1.5, 3.0, default=2.0, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_40_36 = DecimalParameter(0.4, 1.0, default=0.63, space='buy', decimals=3, optimize=False, load=True)
# 48 hours - level 40
buy_pump_pull_threshold_40_48 = DecimalParameter(1.5, 3.0, default=2.0, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_40_48 = DecimalParameter(0.4, 1.0, default=0.84, space='buy', decimals=3, optimize=False, load=True)
# 24 hours - level 50
buy_pump_pull_threshold_50_24 = DecimalParameter(1.5, 3.0, default=1.75, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_50_24 = DecimalParameter(0.4, 1.0, default=0.6, space='buy', decimals=3, optimize=False, load=True)
# 36 hours - level 50
buy_pump_pull_threshold_50_36 = DecimalParameter(1.5, 3.0, default=1.75, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_50_36 = DecimalParameter(0.4, 1.0, default=0.64, space='buy', decimals=3, optimize=False, load=True)
# 48 hours - level 50
buy_pump_pull_threshold_50_48 = DecimalParameter(1.5, 3.0, default=1.75, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_50_48 = DecimalParameter(0.4, 1.0, default=0.85, space='buy', decimals=3, optimize=False, load=True)
# 24 hours - level 60
buy_pump_pull_threshold_60_24 = DecimalParameter(1.5, 3.0, default=1.75, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_60_24 = DecimalParameter(0.4, 1.0, default=0.62, space='buy', decimals=3, optimize=False, load=True)
# 36 hours - level 60
buy_pump_pull_threshold_60_36 = DecimalParameter(1.5, 3.0, default=1.75, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_60_36 = DecimalParameter(0.4, 1.0, default=0.66, space='buy', decimals=3, optimize=False, load=True)
# 48 hours - level 60
buy_pump_pull_threshold_60_48 = DecimalParameter(1.5, 3.0, default=1.75, space='buy', decimals=2, optimize=False, load=True)
buy_pump_threshold_60_48 = DecimalParameter(0.4, 1.0, default=0.9, space='buy', decimals=3, optimize=False, load=True)
# 24 hours - level 70
buy_pump_pull_threshold_70_24 = DecimalParameter(1.5, 3.0, default=1.75, space='buy', decimals=2, optimize=False, load=True)