import ccxt
import talib
import numpy as np

# Configurar el intercambio y par de negociación
exchange = ccxt.binance()
symbol = 'BTC/USDT'

# Obtener los datos de las últimas 200 velas
candles = exchange.fetch_ohlcv(symbol, timeframe='1h', limit=200)
close_prices = np.array([candle for candle in candles])

# Calcular el promedio móvil exponencial (EMA) de 20 periodos
ema20 = talib.EMA(close_prices, timeperiod=20)

# Comparar el último precio de cierre con el EMA20 para determinar la tendencia
last_close_price = close_prices
last_ema20 = ema20

if last_close_price > last_ema20:
print('\033[31m' + 'Vender' + '\033[0m')
else:
print('\033[32m' + 'Comprar' + '\033[0m')
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.