Comments (10)
You will also need to be rather carefull with this - this indicator is using the FULL timerange you're passing in - so in backtesting, it's looking at the whole range and has therefore a lookahead bias (it'll know at all times what the last point in the series was).
You'll need to use it carefully - and apply it in a loop of "smallish" steps to get this right ...
from technical.
i'm ... not quite sure what you are using (and how).
Are you able to share a bit more of the implementation you're using? maybe this will allow us to help you better.
from technical.
I'm attempting to use:
technical/technical/trendline.py
Line 8 in a1e92f3
and
technical/technical/indicators/indicators.py
Line 734 in a1e92f3
for the trendline indicator I'm attempting to use it in the following manner:
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=9)
dataframe_long = resample_to_interval(dataframe, 30)
# Bollinger Bands
bollinger3std = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=3)
dataframe['bb3std_lowerband'] = bollinger3std['lower']
dataframe['bb3std_middleband'] = bollinger3std['mid']
dataframe['bb3std_upperband'] = bollinger3std['upper']
# trendline
trend = segtrends(dataframe_long, field='close')
dataframe_long['trend'] = trend
# Combine the 2 dataframes
dataframe = resampled_merge(dataframe, dataframe_long, fill_na=True)
return dataframe
and to populate the buy indicator:
def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
dataframe.loc[
(
self.good_deal_buy_signal(dataframe) & (
dataframe['close'] > dataframe['resample_30_trend']['Min Line'])), 'buy'] = 1
return dataframe
but also tried to populate the indicator in the following manner as a dataframe is returned:
trend = segtrends(dataframe_long, field='close')
result = dataframe.merge(trend, how='cross')
return result
but then the script seems to hang, I suspect because the merge is quite heavy on performance.
from technical.
a merge is (usually) not heavy on performance - unless you use rather complex conditions.
I've never seen a cross merge though, and i'm not sure that'll work for timeseries.
that result can be rather big (with probably limited benefits, considering that it will combine every row with every other row - i also think that this will lead to a lookahead bias, considering how cross merges work (and you can't really use it anyway as it'll multiply your rows).
What's good_deal_buy_signal()
do? it must return a boolean series (of the correct length!), otherwise this will fail.
from technical.
this is the good_deal_buy function:
def good_deal_buy_signal(self, dataframe):
return dataframe['close'] < dataframe['bb3std_lowerband']
but that alone is working as it should, the fact that I'm trying to figure out is for those indicator that return a dataframe of their own how do you pick the relevant row which hold the information to the row that I'm looking into.
In pseudo code what I'm trying to do is
trend_lines = segtrends(dataframe_long, field='close') dataframe['support'] = trend_lines['Min Line'] dataframe['resistence'] = trend_lines['Max Line']
to then use that information as a guard in the buy signal as
dataframe['close'] > dataframe['support']
from technical.
well - this is not pseudo code, but code how you should actually use it 😆
from technical.
with that code the result of print(dataframe.tail()) is:
with the following populate_indicators function
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=9)
dataframe_long = resample_to_interval(dataframe, 30)
# Bollinger Bands
bollinger3std = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=3)
dataframe['bb3std_lowerband'] = bollinger3std['lower']
dataframe['bb3std_middleband'] = bollinger3std['mid']
dataframe['bb3std_upperband'] = bollinger3std['upper']
trend_lines = segtrends(dataframe_long, field='close')
dataframe_long['support'] = trend_lines['Min Line']
dataframe_long['resistence'] = trend_lines['Max Line']
dataframe = resampled_merge(dataframe, dataframe_long, fill_na=True)
return dataframe
from technical.
i never used trendlines / seglines - maybe it's not supposed to "always" give you value?
try it in a "simple" setup, maybe? without resampling, directly plotting the "dataframe_long" dataframe.
from technical.
with that code the result of print(dataframe.tail()) is:
with the following populate_indicators function
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe['rsi'] = ta.RSI(dataframe, timeperiod=9) dataframe_long = resample_to_interval(dataframe, 30) # Bollinger Bands bollinger3std = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=3) dataframe['bb3std_lowerband'] = bollinger3std['lower'] dataframe['bb3std_middleband'] = bollinger3std['mid'] dataframe['bb3std_upperband'] = bollinger3std['upper'] trend_lines = segtrends(dataframe_long, field='close') dataframe_long['support'] = trend_lines['Min Line'] dataframe_long['resistence'] = trend_lines['Max Line'] dataframe = resampled_merge(dataframe, dataframe_long, fill_na=True) return dataframe
Hey, how are you print the indicators dataframe table?
from technical.
well - print(dataframe.tail())
(as specified above).
I'll now also close this issue as i think the topic has been resolved.
from technical.
Related Issues (20)
- Trend Step Channel - appreciate it HOT 4
- resample_to_interval date shifted HOT 1
- Help with Trend Trader Strategy HOT 1
- ichimoku different value proposal HOT 1
- How to import external data to populate entry/exit trend conditions HOT 14
- Multiple timeframe merge HOT 10
- Laguerre RSI wrong computation HOT 3
- ```crossed``` function throws error with numpy integers
- utils bug HOT 4
- How to plot segtrends or gentrends using freqtrade plot-dataframe ? HOT 1
- Phase Change Index HOT 18
- I try to convert Predictive Ranges [LuxAlgo] to the py, whats the problem? HOT 7
- Involvement of Heikenashi candles could be helpful in trend prediction HOT 1
- Help needed with: AttributeError: 'SSL' object has no attribute 'copy' HOT 3
- warning util.py
- 16 tests failed HOT 4
- Pandas warning when setting fillna(0) on RMI calc HOT 2
- Issues with PMAX indicator HOT 1
- A few Pinescript lines HOT 2
- Error thrown at numpy_rolling_window HOT 3
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 technical.