Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEMA200 to long? #10201

Closed
myNextCoder opened this issue May 12, 2024 · 10 comments
Closed

TEMA200 to long? #10201

myNextCoder opened this issue May 12, 2024 · 10 comments
Labels
Question Questions - will be closed after some period of inactivity. Strategy assistance Help with a strategy

Comments

@myNextCoder
Copy link

Describe your environment

  • Operating system: Windows Server 2022
  • Python Version: Current Miniconda (python -V)
  • CCXT version: _____ (pip freeze | grep ccxt)
  • Freqtrade Version: 2024.3 (freqtrade -V or docker compose run --rm freqtrade -V for Freqtrade running in docker)

Your question

While EMA 200 or TEMA 3 for example works correctly, it seems, that TEMA 200 is something like "out of bounds". Do you know the issue, is there a workaround, (different notation?)

This notation works fine for timeperiod 3, for example, but not for 200:
dataframe['tema200'] = ta.TEMA(dataframe, timeperiod=200)

I get no error, but for .iloc[-1] there is nan as the value, even after multiple hours (1m timeframe).
For EMA200 I get the correct float value.

Background: I prefer TEMA200 instead of EMA200, due to its fast behavior.

Ask the question you have not been able to find an answer in the Documentation

@myNextCoder myNextCoder added the Question Questions - will be closed after some period of inactivity. label May 12, 2024
@stash86
Copy link
Contributor

stash86 commented May 12, 2024

What is your startup_candle_count?

@Axel-CH
Copy link
Contributor

Axel-CH commented May 13, 2024

You are using too much candle history for your indicator.
I would suggest you to use an informative pair with a higher timeframe as input of your TEMA order to get the history perspective that you want.
200 candles of one minute is near 13 candles of 15 minutes.

You can add informative pairs by Following instructions from the informative pair documentation

@Axel-CH Axel-CH added the Strategy assistance Help with a strategy label May 13, 2024
@stash86
Copy link
Contributor

stash86 commented May 13, 2024

it's not "too much". I'm using that length as well. As long as they use the proper startup_candle_count, then there would be no issue

@Axel-CH
Copy link
Contributor

Axel-CH commented May 13, 2024

Glad to hear that @stash86 , you are right the live default ohlcv_candle_limit is 500.
So It should work

@stash86
Copy link
Contributor

stash86 commented May 13, 2024

actually it's 1000 for binance, which is the necessary length for TEMA200. If they are on different exchange, then yes they may have issues

@myNextCoder
Copy link
Author

I thank you for your inputs. I was told, that informative pairs need to "warm up" after Bot start first. To access the value instantly, I may use the formula, to calculate TEMA from EMA:
TEMA = 3EMA – 3EMA(EMA) + EMA(EMA(EMA))

@stash86
Copy link
Contributor

stash86 commented May 13, 2024

there is no such thing as warm up. All data and indicators are ready immediately

@myNextCoder
Copy link
Author

Ok, in that case, I have a look at it, I thank you :)

@xmatthias
Copy link
Member

xmatthias commented May 14, 2024

well TEMA takes about 3x the number you pass in (it's an EMA20 of an EMA20 of an EMA20, after all.

For simplicity's sake (it makes below numbers AND screenshots shorter), assume an EMA10.
What the calculation will do is an EMA10 - on top of an EMA10 - on top of an EMA10

To calculate the first EMA10 - you need 9 startup candles - so the very first row that will have data is row number 10.
To calculate DEMA (EMA10 on top of EMA10) - you need already 18 rows that will remain NaN.
For the third "round" - you then need 27 startup candles.

What this will come down to is the following picture:
image

(code to generate the below)

dataframe['EMA-10'] = ta.EMA(dataframe, timeperiod=10)
dataframe['DEMA-10'] = ta.EMA(dataframe['EMA-10'], timeperiod=10)
dataframe['TEMA-10_1'] = ta.EMA(dataframe['DEMA-10'], timeperiod=10)
dataframe['TEMA-10_2'] = dataframe['EMA-10']*3 - 3*dataframe['DEMA-10'] + dataframe['TEMA-10_1']

dataframe['TEMA-10'] = ta.TEMA(dataframe, timeperiod=10)

Notice that the last 2 columns have identical values - though one was calculated with talib, and one "manually".

So in any case - TEMA has a startup value of 3 * (x-1) (with x being the timerange) - so something around 597 (use 600 to be safe) - and not 200 - which is what the mind would have you believe.

Specifying that as startup candle count should work on all supported exchanges.

@myNextCoder
Copy link
Author

Sorry for my late reply, I thank you for your detailed answer. Absolutely great your table :) Here it is easy to see, what time the bot is consuming. I see, that after about 600 minutes, I would have had the desired result. Now I used the workaround of TEMA40 on informative timeframe 5m. Here I have no issue anymore. EMA200 would be far more easy, but after my analysis on Tradingview, if I want to enter only, when the line is below the price-action, I have less opportunities, during the bullish period, when the trend grows. TEMA200 lets me buy lower. (This is only one of multiple conditions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Questions - will be closed after some period of inactivity. Strategy assistance Help with a strategy
Projects
None yet
Development

No branches or pull requests

4 participants