Comments (3)
buy_ap: CategoricalParameter([14, 15, 16], default=14, space = "buy", optimize=True, load=True)
(and all similar occurances) are type assignments only (buy_ap will still be None after this line).
you'll need to use buy_ap = CategoricalParameter([14, 15, 16], default=14, space = "buy", optimize=True, load=True)
in each instance.
from freqtrade-strategies.
oh ok :) sorry for that. thanks a lot. after that i will use =) instead of :)
from freqtrade-strategies.
`
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
alphatrend = self.generateAlphaTrend(dataframe)
dataframe['k1'] = alphatrend['k1']
dataframe['k2'] = alphatrend['k2']
dataframe['signal'] = alphatrend['signal']
# for elis leverage
if self.can_use_elis_leverage == True:
dataframe['elis'] = alphatrend['elis']
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
# (qtpylib.crossed_above(dataframe['k1'] , dataframe['k2']))
(dataframe['k1'] > dataframe['k2']) &
(dataframe['signal'].shift(1) == 'sell')
),
'enter_long',
] = 1
dataframe.loc[
(
# (qtpylib.crossed_below(dataframe['k1'] , dataframe['k2']))
(dataframe['k1'] < dataframe['k2']) &
(dataframe['signal'].shift(1) == 'buy')
),
"enter_short",
] = 1
return dataframe
def generateAlphaTrend(self, dataframe: DataFrame):
df = dataframe.copy()
# ap = 14
ap = self.at_period
# coeff = 1.4
coeff = self.at_coeff
atr = ta.ATR(df['high'], df['low'], df['close'], timeperiod=ap)
at = 'k1'
at2 = 'k2'
noVolumeData = False
upt = []
downT = []
AlphaTrend = [0.0]
rsi = ta.RSI(df['close'], timeperiod=ap)
k1 = []
k2 = []
mfi = ta.MFI(df['high'], df['low'], df['close'], df['volume'], timeperiod=ap)
# print(at)
for i in range(len(df['low'])):
if pd.isna(atr[i]):
upt.append(0)
else:
upt.append(df['low'][i] - (atr[i] * coeff))
for i in range(len(df['high'])):
if pd.isna(atr[i]):
downT.append(0)
else:
downT.append(df['high'][i] + (atr[i] * coeff))
for i in range(1, len(df['close'])):
if noVolumeData is True and rsi[i] >= 50:
if upt[i] < AlphaTrend[i - 1]:
AlphaTrend.append(AlphaTrend[i - 1])
else:
AlphaTrend.append(upt[i])
elif noVolumeData is False and mfi[i] >= 50:
if upt[i] < AlphaTrend[i - 1]:
AlphaTrend.append(AlphaTrend[i - 1])
else:
AlphaTrend.append(upt[i])
else:
if downT[i] > AlphaTrend[i - 1]:
AlphaTrend.append(AlphaTrend[i - 1])
else:
AlphaTrend.append(downT[i])
for i in range(len(AlphaTrend)):
if i < 2:
k2.append(0)
k1.append(AlphaTrend[i])
else:
k2.append(AlphaTrend[i - 2])
k1.append(AlphaTrend[i])
df[at] = pd.DataFrame(data=k1, columns=['k1'])
df[at2] = pd.DataFrame(data=k2, columns=['k2'])
conditions = [ df[at] > df[at2], (df[at] == df[at2]), df[at] < df[at2] ]
choices = [ "buy", 'same', 'sell' ]
df["basic_signal"] = np.select(conditions, choices, default=np.nan)
previous = "same"
for i in range(len(df)):
if df.loc[i,"k1"] == df.loc[i,"k2"]:
comment = previous
else:
comment = "buy" if df.loc[i,"k1"] > df.loc[i,"k2"] else "sell"
df.loc[i,"signal"] = comment
previous = comment
if self.can_use_elis_leverage == True:
elisGenerate = self.elis(dataframe)
df['elis'] = elisGenerate['elis']
df.fillna(0, inplace=True)
# df.to_csv('df_at.csv', index = False, header=True)
return df
####### calculate AlphaTrend #######
`
I hope it works. I've been using it for about a year. the profit is pretty low in the strategy I made. I hope you have a better strategy. 👍 :))
from freqtrade-strategies.
Related Issues (20)
- How to config two or more stategies to run on one server? HOT 1
- External Signal provider HOT 3
- GodStra strat can't find ta module HOT 3
- How to get funding rate to use as indicator on freqtrade HOT 8
- Volatility Strategy HOT 2
- Lookahead for Strategy002 and 004 HOT 5
- cannot use the timeframe i want HOT 4
- GodStra not results available HOT 1
- GodStraHo: Impossible to load Strategy 'GodStraHo'. This class does not exist or contains Python code errors.
- GodStraHo: Impossible to load Strategy 'GodStraHo'. This class does not exist or contains Python code errors. #294 HOT 3
- Unable to retrieve candlestick information from dataframe HOT 1
- BB_RSI_ATR HOT 5
- Momentum Strategy HOT 4
- ta not installing on Google cloud instance and all futures strategies are not working HOT 3
- No module named 'ta' HOT 1
- incorrect times displayed in FreqUI HOT 4
- Error using MACD indicator from qtpylib indicators.py
- WARNING - Unable to analyze candle (OHLCV) data for pair {pair}: Dataframe returned from strategy has mismatching last close price. HOT 2
- finta problem HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freqtrade-strategies.