NESESITO QUE ME HAGAN UN BOT CON ESTA INFORMACION EN PYTON

MQL5 Esperti Python

Specifiche


NESESITO QUE ME HAGAN UN BOT CON ESTA INFORMACION EN PYTON 









mport ccxt

import pandas as pd
import numpy as np
import ta

# Configuración de la API
exchange = ccxt.binance()  # Cambia a tu exchange preferido
symbol = 'BTC/USDT'  # Activo a operar
timeframe = '1h'  # Marco temporal
risk_percentage = 0.02  # Riesgo por operación
stop_loss_percentage = 0.02  # 2% stop loss
take_profit_percentage = 0.04  # 4% take profit

# Función para obtener datos históricos
def get_historical_data(symbol, timeframe):
    bars = exchange.fetch_ohlcv(symbol, timeframe)
    df = pd.DataFrame(bars, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
    df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
    return df

# Función para calcular indicadores
def calculate_indicators(df):
    df['RSI'] = ta.momentum.RSIIndicator(df['close']).rsi()
    df['MACD'] = ta.trend.MACD(df['close']).macd()
    df['Signal'] = ta.trend.MACD(df['close']).macd_signal()
    df['OBV'] = ta.volume.OnBalanceVolumeIndicator(df['close'], df['volume']).on_balance_volume()
    df['Stochastic'] = ta.momentum.StochasticOscillator(df['high'], df['low'], df['close']).stoch()
    return df

# Estrategia de Trading
def strategy(df):
    last_row = df.iloc[-1]
    
    # Condiciones de compra
    if (last_row['RSI'] < 30) and (last_row['MACD'] > last_row['Signal']):
        return 'buy'
    
    # Condiciones de venta
    elif (last_row['RSI'] > 70) and (last_row['MACD'] < last_row['Signal']):
        return 'sell'
    
    return 'hold'

# Función de gestión de riesgo
def calculate_position_size(balance, risk_percentage):
    return balance * risk_percentage

# Función para ejecutar ordenes con stop loss y take profit
def execute_order(signal, position_size):
    market_price = exchange.fetch_ticker(symbol)['last']
    
    if signal == 'buy':
        # Ejecutar orden de compra
        order = exchange.create_market_order(symbol, 'buy', position_size)
        # Calcular niveles de stop loss y take profit
        stop_loss_price = market_price * (1 - stop_loss_percentage)
        take_profit_price = market_price * (1 + take_profit_percentage)
        
        # Establecer stop loss
        exchange.create_order(symbol, 'stop_market', 'sell', position_size, stop_loss_price)
        # Establecer take profit
        exchange.create_limit_order(symbol, 'sell', position_size, take_profit_price)

    elif signal == 'sell':
        # Ejecutar orden de venta
        order = exchange.create_market_order(symbol, 'sell', position_size)
        # Calcular niveles de stop loss y take profit
        stop_loss_price = market_price * (1 + stop_loss_percentage)
        take_profit_price = market_price * (1 - take_profit_percentage)
        
        # Establecer stop loss
        exchange.create_order(symbol, 'stop_market', 'buy', position_size, stop_loss_price)
        # Establecer take profit
        exchange.create_limit_order(symbol, 'buy', position_size, take_profit_price)

# Loop principal del bot
def run_bot():
    balance = exchange.fetch_balance()['total']['USDT']  # Ajusta según tu activo
    df = get_historical_data(symbol, timeframe)
    df = calculate_indicators(df)
    
    signal = strategy(df)
    
    if signal in ['buy', 'sell']:
        position_size = calculate_position_size(balance, risk_percentage)
        execute_order(signal, position_size)

# Ejecutar el bot
if _name_ == "_main_":
    run_bot()

Con risposta

1
Sviluppatore 1
Valutazioni
(184)
Progetti
315
24%
Arbitraggio
23
35% / 13%
In ritardo
24
8%
In elaborazione
Pubblicati: 3 codici
2
Sviluppatore 2
Valutazioni
(1)
Progetti
1
0%
Arbitraggio
1
0% / 0%
In ritardo
0
Gratuito
Ordini simili
✅ Validation checks: - Verify calculated lot is within broker's min/max limits - Round lot size to broker's lot step - Verify sufficient free margin before opening trade - Handle edge cases (very small accounts, very large SL, etc.) The lot calculation MUST be universal and work perfectly on any symbol without manual configuration. TELEGRAM NOTIFICATIONS (CRITICAL REQUIREMENT): The EA must send detailed

Informazioni sul progetto

Budget
30+ USD