Mar-20-2022, 07:25 AM
https://imgur.com/UYtzroz
if help also explanation like this
If you have a suggestion, I would appreciate it if you could edit the code, I tried a lot, but I could not get a successful result.
if (float(e8[index])) - float(e13[index] == True):According to your e8 and e13 values from your previous post this is:
if 396.7588162749833 - 396.95757807407034 == True:First off, you never compare anything to True or False. True or False are results of a comparison. a > 2 will be True or False. It will be True if a=3 and False if a=1. It does not make any sense to ask:
if (a > 2) == True:This will be True if a > 2, otherwise False. The addition of "== True" has no effect.
if e8[index] - e13[index] > 0:If you are uneasy about operator precedence you can wrap the subtraction in parenthesis.
if (e8[index] - e13[index]) > 0:Your use doesn't make any sense:
if (e8[index]) - e13[index] > 0:Wrapping e8[index] in parenthesis doesn't affect anything. It doesn't hurt anything, except understanding. It made me look at the code twice, wondering what the parenthesis were for before realizing they were doing nothing.
bars = exchange.fetch_ohlcv(symbol, timeframe=zamanAraligi, since=None, limit=500) df = pd.DataFrame(bars, columns=["timestamp", "open", "high", "low", "close", "volume"]) #ema control e8 = ta.ma("ema", df.close, length=8) e13 = ta.ma('ema', df.close, length=13) e21 = ta.ma('ema', df.close, length=21) e55 = ta.ma('ema', df.close, length=55) #ema rating total = 0 if any(e8[-1] > e13[-1]): total += 1 else: total -= 1 if any(e13[-1] > e21[-1]): total += 1 else: total -= 1 if any(e21[-1] > e55[-1]): total += 1 else: total -= 1 print("Ema 8 =", e8[-1]) print("Ema 13 =", e13[-1]) print("Ema 21 =", e21[-1]) print("Ema 55 =", e55[-1]) print("rating =", total)I am stunned that you can used Pandas technical analysis package and not know how how if statements or comparisons work. It makes me wonder if comparing e8[-1] against e13[-1] makes any sense at all.
bars = exchange.fetch_ohlcv(symbol, timeframe=zamanAraligi, since=None, limit=500) df = pd.DataFrame(bars, columns=["timestamp", "open", "high", "low", "close", "volume"]) #ema control e8 = ta.ma("ema", df.close, length=8) e13 = ta.ma('ema', df.close, length=13) e21 = ta.ma('ema', df.close, length=21) e55 = ta.ma('ema', df.close, length=55) total = 0 if any(e8 > e13): total += 1 else: total -= 1 if any(e13 > e21): total += 1 else: total -= 1 if any(e21 > e55): total += 1 else: total -= 1 print("rating =", total)no matter what I do it always returns the result as 3 but this result is not correct, it always returns 3 where the result should be 2 or -1 where it should be.
if e8[-1] > e13[-1]:
Error:ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().