Códigos Bot MT5 Abiertos en Colombia

Automatización avanzada para optimizar estrategias de trading en MetaTrader 5. Herramientas personalizables y eficientes para maximizar tus resultados. Código Libre Para Cualquier Trader.

Ver Brokers Regulados en Colombia

Aviso Legal: Estos modelos de código no garantizan ningún tipo de inversión. Este material está disponible bajo la responsabilidad de cada persona, quien deberá manejar correctamente la gestión de capital. El trading conlleva riesgos significativos.

Código Abierto

Nuestros Bots de Trading

Descarga y personaliza estos Expert Advisors (EA) para MetaTrader 5. Todos los códigos son de libre uso y modificación.

Bot Interés Compuesto 3%

Recomendado para cuentas de $1,000 USD

Activo
bot_interes_compuesto.mq5
//+------------------------------------------------------------------+
//|                                           bot_mejorado.mq5       |
//+------------------------------------------------------------------+
#property copyright "Your Name"
#property link      ""
#property version   "1.03"
#property strict

#include <Trade/Trade.mqh>

// Parámetros de entrada
input double StopLossPips = 20;      // Stop Loss en pips
input double TakeProfitPips = 60;    // Take Profit en pips
input int MagicNumber = 123456;      // Número mágico
input int PeriodMA = 20;             // Periodo de la Media Móvil
input int LookbackPeriod = 5;        // Reducido para aumentar frecuencia
input bool EnableDebug = false;      // Habilitar mensajes de debug
input double RiskPercentage = 3.0;   // Porcentaje del capital para arriesgar

// Variables globales
double PointPip;
CTrade trade;
int maHandle;

//+------------------------------------------------------------------+
//| Expert initialization function                                     |
//+------------------------------------------------------------------+
int OnInit()
{
    PointPip = _Point * ((_Digits == 3 || _Digits == 5) ? 10 : 1);
    trade.SetExpertMagicNumber(MagicNumber);
    trade.SetDeviationInPoints(10);

    maHandle = iMA(_Symbol, PERIOD_CURRENT, PeriodMA, 0, MODE_SMA, PRICE_CLOSE);
    if (maHandle == INVALID_HANDLE)
    {
        Print("Error al inicializar Media Móvil.");
        return(INIT_FAILED);
    }

    Print("EA iniciado correctamente en: ", _Symbol);
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                   |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    if (maHandle != INVALID_HANDLE)
        IndicatorRelease(maHandle);
}

//+------------------------------------------------------------------+
//| Expert tick function                                               |
//+------------------------------------------------------------------+
void OnTick()
{
    double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
    double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

    if (EnableDebug)
        PrintFormat("Precio Ask: %f, Precio Bid: %f", ask, bid);

    if (HayOperacionesAbiertas())
    {
        TrailingStop(StopLossPips * PointPip);
        return;
    }

    MqlRates rates[];
    ArraySetAsSeries(rates, true);
    if (CopyRates(_Symbol, PERIOD_CURRENT, 0, LookbackPeriod, rates) != LookbackPeriod)
    {
        Print("Error copiando datos históricos.");
        return;
    }

    double maxHigh = rates[0].high, minLow = rates[0].low;
    for (int i = 1; i < LookbackPeriod; i++)
    {
        if (rates[i].high > maxHigh) maxHigh = rates[i].high;
        if (rates[i].low < minLow) minLow = rates[i].low;
    }

    double maArray[1];
    if (CopyBuffer(maHandle, 0, 0, 1, maArray) != 1)
        return;

    bool signalCompra = (bid > maArray[0] && bid > maxHigh - (2 * PointPip));
    bool signalVenta = (ask < maArray[0] && ask < minLow + (2 * PointPip));

    if (signalCompra)
        AbrirCompra(ask);
    else if (signalVenta)
        AbrirVenta(bid);
}

//+------------------------------------------------------------------+
//| Función para calcular el tamaño del lote                          |
//+------------------------------------------------------------------+
double CalcularLote(double stopLossPips)
{
    double accountBalance = AccountInfoDouble(ACCOUNT_BALANCE);
    double riskAmount = (RiskPercentage / 100.0) * accountBalance;
    double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
    double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
    double lotSize = riskAmount / ((stopLossPips * PointPip / tickSize) * tickValue);
    return NormalizeDouble(lotSize, 2);
}

void AbrirCompra(double ask)
{
    double lotSize = CalcularLote(StopLossPips);
    double stopLoss = ask - (StopLossPips * PointPip);
    double takeProfit = ask + (TakeProfitPips * PointPip);

    if (trade.Buy(lotSize, _Symbol, ask, stopLoss, takeProfit, "Compra"))
        Print("Compra abierta exitosamente. Ticket: ", trade.ResultOrder());
    else
        Print("Error al abrir compra: ", GetLastError());
}

void AbrirVenta(double bid)
{
    double lotSize = CalcularLote(StopLossPips);
    double stopLoss = bid + (StopLossPips * PointPip);
    double takeProfit = bid - (TakeProfitPips * PointPip);

    if (trade.Sell(lotSize, _Symbol, bid, stopLoss, takeProfit, "Venta"))
        Print("Venta abierta exitosamente. Ticket: ", trade.ResultOrder());
    else
        Print("Error al abrir venta: ", GetLastError());
}

bool HayOperacionesAbiertas()
{
    for (int i = 0; i < PositionsTotal(); i++)
    {
        if (PositionSelectByTicket(PositionGetTicket(i)) &&
            PositionGetInteger(POSITION_MAGIC) == MagicNumber)
            return true;
    }
    return false;
}

void TrailingStop(double stopLossPips)
{
    for (int i = 0; i < PositionsTotal(); i++)
    {
        if (!PositionSelectByTicket(PositionGetTicket(i)))
            continue;

        double currentSL = PositionGetDouble(POSITION_SL);
        double currentPrice = PositionGetDouble(POSITION_PRICE_CURRENT);
        double newSL = NormalizeDouble(currentPrice - stopLossPips, _Digits);

        if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && newSL > currentSL)
            trade.PositionModify(PositionGetTicket(i), newSL, PositionGetDouble(POSITION_TP));
        else if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && newSL < currentSL)
            trade.PositionModify(PositionGetTicket(i), newSL, PositionGetDouble(POSITION_TP));
    }
}

Bot de Cobertura (Hedge)

Cierre manual en ganancia - Cuentas de $100 USD

Activo
bot_cobertura.mq5
//+------------------------------------------------------------------+
//|                                           bot_cobertura.mq5       |
//+------------------------------------------------------------------+
#include <Trade/Trade.mqh>

// Parámetros configurables
input double TakeProfitPrincipalPips = 60;
input double StopLossPrincipalPips = 10;
input double TakeProfitHedgePips = 7;
input double StopLossHedgePips = 20;
input double LotSizePrincipal = 0.1;
input double LotSizeHedge = 0.05;
input int MagicNumberPrincipal = 123456;
input int MagicNumberHedge = 654321;
input int LookbackPeriod = 10;
input double ToleranciaPips = 5;
input double TrailingStopPips = 17;

CTrade trade;
double PointPip;

int OnInit()
{
    PointPip = _Point * ((_Digits == 3 || _Digits == 5) ? 10 : 1);
    trade.SetExpertMagicNumber(MagicNumberPrincipal);
    Print("Bot inicializado correctamente.");
    return(INIT_SUCCEEDED);
}

void OnTick()
{
    if (HayOperacionesAbiertas(MagicNumberPrincipal))
        return;

    double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
    double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

    double soporte = CalcularSoporte(LookbackPeriod);
    double resistencia = CalcularResistencia(LookbackPeriod);

    if (PrecioCercaDeResistencia(resistencia, ToleranciaPips))
    {
        if (AbrirVenta(bid))
            Print("Venta abierta cerca de resistencia: ", resistencia);
    }
    else if (PrecioCercaDeSoporte(soporte, ToleranciaPips))
    {
        if (AbrirCompra(ask))
            Print("Compra abierta cerca de soporte: ", soporte);
    }
}

double CalcularSoporte(int lookbackPeriod)
{
    MqlRates rates[];
    ArraySetAsSeries(rates, true);
    if (CopyRates(_Symbol, PERIOD_CURRENT, 0, lookbackPeriod, rates) < lookbackPeriod)
        return 0;

    double minLow = rates[0].low;
    for (int i = 1; i < lookbackPeriod; i++)
    {
        if (rates[i].low < minLow)
            minLow = rates[i].low;
    }
    return minLow;
}

double CalcularResistencia(int lookbackPeriod)
{
    MqlRates rates[];
    ArraySetAsSeries(rates, true);
    if (CopyRates(_Symbol, PERIOD_CURRENT, 0, lookbackPeriod, rates) < lookbackPeriod)
        return 0;

    double maxHigh = rates[0].high;
    for (int i = 1; i < lookbackPeriod; i++)
    {
        if (rates[i].high > maxHigh)
            maxHigh = rates[i].high;
    }
    return maxHigh;
}

bool PrecioCercaDeResistencia(double resistencia, double toleranciaPips)
{
    double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
    return (MathAbs(ask - resistencia) <= toleranciaPips * PointPip);
}

bool PrecioCercaDeSoporte(double soporte, double toleranciaPips)
{
    double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
    return (MathAbs(bid - soporte) <= toleranciaPips * PointPip);
}

bool AbrirVenta(double bid)
{
    double stopLoss = bid + (StopLossPrincipalPips * PointPip);
    double takeProfit = bid - (TakeProfitPrincipalPips * PointPip);
    if (trade.Sell(LotSizePrincipal, _Symbol, bid, stopLoss, takeProfit, "Venta Principal"))
    {
        double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
        AbrirCoberturaCompra(ask);
        return true;
    }
    return false;
}

bool AbrirCompra(double ask)
{
    double stopLoss = ask - (StopLossPrincipalPips * PointPip);
    double takeProfit = ask + (TakeProfitPrincipalPips * PointPip);
    if (trade.Buy(LotSizePrincipal, _Symbol, ask, stopLoss, takeProfit, "Compra Principal"))
    {
        double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
        AbrirCoberturaVenta(bid);
        return true;
    }
    return false;
}

bool AbrirCoberturaCompra(double ask)
{
    double stopLoss = ask - (StopLossHedgePips * PointPip);
    double takeProfit = ask + (TakeProfitHedgePips * PointPip);
    return trade.Buy(LotSizeHedge, _Symbol, ask, stopLoss, takeProfit, "Cobertura - Compra");
}

bool AbrirCoberturaVenta(double bid)
{
    double stopLoss = bid + (StopLossHedgePips * PointPip);
    double takeProfit = bid - (TakeProfitHedgePips * PointPip);
    return trade.Sell(LotSizeHedge, _Symbol, bid, stopLoss, takeProfit, "Cobertura - Venta");
}

bool HayOperacionesAbiertas(int magicNumber)
{
    for (int i = 0; i < PositionsTotal(); i++)
    {
        if (PositionSelectByTicket(PositionGetTicket(i)) &&
            PositionGetInteger(POSITION_MAGIC) == magicNumber)
            return true;
    }
    return false;
}

Bot Tendencia RSR30

Cierre manual en ganancia - Cuentas de $100 USD

Activo
RSR30_Bot.mq5
//+------------------------------------------------------------------+
//|                                                RSR30_Bot.mq5      |
//+------------------------------------------------------------------+
#property copyright "Tu Nombre"
#property version   "1.02"
#property strict

#include <Trade/Trade.mqh>

input double LotSize = 0.01;
input double StopLossPips = 30;
input double TakeProfitPips = 50;
input int MagicNumber = 123456;
input int PeriodEMA4 = 4;
input int PeriodEMA30 = 30;
input bool EnableDebug = false;
input bool Enable911 = true;
input double RiskFactor911 = 1.5;

double PointPip;
CTrade trade;
int ema4Handle, ema30Handle;

int OnInit()
{
    PointPip = _Point * ((_Digits == 3 || _Digits == 5) ? 10 : 1);
    trade.SetExpertMagicNumber(MagicNumber);

    ema4Handle = iMA(_Symbol, PERIOD_CURRENT, PeriodEMA4, 0, MODE_EMA, PRICE_CLOSE);
    ema30Handle = iMA(_Symbol, PERIOD_CURRENT, PeriodEMA30, 0, MODE_EMA, PRICE_CLOSE);

    if (ema4Handle == INVALID_HANDLE || ema30Handle == INVALID_HANDLE)
    {
        Print("Error al inicializar EMAs.");
        return(INIT_FAILED);
    }

    Print("EA RSR30 iniciado correctamente en: ", _Symbol);
    return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
    if (ema4Handle != INVALID_HANDLE) IndicatorRelease(ema4Handle);
    if (ema30Handle != INVALID_HANDLE) IndicatorRelease(ema30Handle);
}

void OnTick()
{
    double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
    double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

    if (HayOperacionesAbiertas())
    {
        TrailingStop(StopLossPips * PointPip);
        return;
    }

    double ema4Array[1], ema30Array[1];
    if (CopyBuffer(ema4Handle, 0, 0, 1, ema4Array) != 1 || 
        CopyBuffer(ema30Handle, 0, 0, 1, ema30Array) != 1)
        return;

    double ema4 = ema4Array[0];
    double ema30 = ema30Array[0];

    bool signalCompra = (bid > ema30 && bid < ema4);
    bool signalVenta = (ask < ema30 && ask > ema4);

    if (signalCompra)
        AbrirCompra(ask);
    else if (signalVenta)
        AbrirVenta(bid);
}

void AbrirCompra(double ask)
{
    double stopLoss = ask - (StopLossPips * PointPip);
    double takeProfit = ask + (TakeProfitPips * PointPip);

    if (trade.Buy(LotSize, _Symbol, ask, stopLoss, takeProfit, "Compra"))
    {
        Print("Compra abierta exitosamente.");
        if (Enable911)
            ColocarOrden911(POSITION_TYPE_SELL, ask + RiskFactor911 * StopLossPips * PointPip, stopLoss);
    }
}

void AbrirVenta(double bid)
{
    double stopLoss = bid + (StopLossPips * PointPip);
    double takeProfit = bid - (TakeProfitPips * PointPip);

    if (trade.Sell(LotSize, _Symbol, bid, stopLoss, takeProfit, "Venta"))
    {
        Print("Venta abierta exitosamente.");
        if (Enable911)
            ColocarOrden911(POSITION_TYPE_BUY, bid - RiskFactor911 * StopLossPips * PointPip, stopLoss);
    }
}

void ColocarOrden911(int type, double price, double stopLoss)
{
    ENUM_ORDER_TYPE_TIME timeType = ORDER_TIME_GTC;
    datetime expiration = 0;

    if (type == POSITION_TYPE_BUY)
        trade.BuyStop(LotSize, price, _Symbol, stopLoss, price + (TakeProfitPips * PointPip), timeType, expiration, "Orden 911");
    else if (type == POSITION_TYPE_SELL)
        trade.SellStop(LotSize, price, _Symbol, stopLoss, price - (TakeProfitPips * PointPip), timeType, expiration, "Orden 911");
}

bool HayOperacionesAbiertas()
{
    for (int i = 0; i < PositionsTotal(); i++)
    {
        if (PositionSelectByTicket(PositionGetTicket(i)) &&
            PositionGetInteger(POSITION_MAGIC) == MagicNumber)
            return true;
    }
    return false;
}

void TrailingStop(double stopLossPips)
{
    for (int i = 0; i < PositionsTotal(); i++)
    {
        if (!PositionSelectByTicket(PositionGetTicket(i))) continue;

        double currentSL = PositionGetDouble(POSITION_SL);
        double currentPrice = PositionGetDouble(POSITION_PRICE_CURRENT);
        double newSL = NormalizeDouble(currentPrice - stopLossPips, _Digits);

        if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && newSL > currentSL)
            trade.PositionModify(PositionGetTicket(i), newSL, PositionGetDouble(POSITION_TP));
        else if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && newSL < currentSL)
            trade.PositionModify(PositionGetTicket(i), newSL, PositionGetDouble(POSITION_TP));
    }
}

Bot EUR/USD 60% Anual

Automático con cierre manual hasta 300% - Cuentas de $100

Premium
bot_eurusd_premium.mq5
//+------------------------------------------------------------------+
//|                                        bot_eurusd_premium.mq5     |
//+------------------------------------------------------------------+
#property copyright "Your Name"
#property version   "1.03"
#property strict

#include <Trade/Trade.mqh>

input double StopLossPips = 20;
input double TakeProfitPips = 60;
input int MagicNumber = 123456;
input int PeriodMA = 20;
input int LookbackPeriod = 5;
input bool EnableDebug = false;
input double RiskPercentage = 3.0;

double PointPip;
CTrade trade;
int maHandle;

int OnInit()
{
    PointPip = _Point * ((_Digits == 3 || _Digits == 5) ? 10 : 1);
    trade.SetExpertMagicNumber(MagicNumber);
    trade.SetDeviationInPoints(10);

    maHandle = iMA(_Symbol, PERIOD_CURRENT, PeriodMA, 0, MODE_SMA, PRICE_CLOSE);
    if (maHandle == INVALID_HANDLE)
    {
        Print("Error al inicializar Media Móvil.");
        return(INIT_FAILED);
    }

    Print("EA iniciado correctamente en: ", _Symbol);
    return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
    if (maHandle != INVALID_HANDLE)
        IndicatorRelease(maHandle);
}

void OnTick()
{
    double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
    double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

    if (HayOperacionesAbiertas())
    {
        TrailingStop(StopLossPips * PointPip);
        return;
    }

    MqlRates rates[];
    ArraySetAsSeries(rates, true);
    if (CopyRates(_Symbol, PERIOD_CURRENT, 0, LookbackPeriod, rates) != LookbackPeriod)
        return;

    double maxHigh = rates[0].high, minLow = rates[0].low;
    for (int i = 1; i < LookbackPeriod; i++)
    {
        if (rates[i].high > maxHigh) maxHigh = rates[i].high;
        if (rates[i].low < minLow) minLow = rates[i].low;
    }

    double maArray[1];
    if (CopyBuffer(maHandle, 0, 0, 1, maArray) != 1)
        return;

    bool signalCompra = (bid > maArray[0] && bid > maxHigh - (2 * PointPip));
    bool signalVenta = (ask < maArray[0] && ask < minLow + (2 * PointPip));

    if (signalCompra)
        AbrirCompra(ask);
    else if (signalVenta)
        AbrirVenta(bid);
}

double CalcularLote(double stopLossPips)
{
    double accountBalance = AccountInfoDouble(ACCOUNT_BALANCE);
    double riskAmount = (RiskPercentage / 100.0) * accountBalance;
    double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
    double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
    double lotSize = riskAmount / ((stopLossPips * PointPip / tickSize) * tickValue);
    return NormalizeDouble(lotSize, 2);
}

void AbrirCompra(double ask)
{
    double lotSize = CalcularLote(StopLossPips);
    double stopLoss = ask - (StopLossPips * PointPip);
    double takeProfit = ask + (TakeProfitPips * PointPip);

    if (trade.Buy(lotSize, _Symbol, ask, stopLoss, takeProfit, "Compra"))
        Print("Compra abierta exitosamente.");
    else
        Print("Error al abrir compra: ", GetLastError());
}

void AbrirVenta(double bid)
{
    double lotSize = CalcularLote(StopLossPips);
    double stopLoss = bid + (StopLossPips * PointPip);
    double takeProfit = bid - (TakeProfitPips * PointPip);

    if (trade.Sell(lotSize, _Symbol, bid, stopLoss, takeProfit, "Venta"))
        Print("Venta abierta exitosamente.");
    else
        Print("Error al abrir venta: ", GetLastError());
}

bool HayOperacionesAbiertas()
{
    for (int i = 0; i < PositionsTotal(); i++)
    {
        if (PositionSelectByTicket(PositionGetTicket(i)) &&
            PositionGetInteger(POSITION_MAGIC) == MagicNumber)
            return true;
    }
    return false;
}

void TrailingStop(double stopLossPips)
{
    for (int i = 0; i < PositionsTotal(); i++)
    {
        if (!PositionSelectByTicket(PositionGetTicket(i))) continue;

        double currentSL = PositionGetDouble(POSITION_SL);
        double currentPrice = PositionGetDouble(POSITION_PRICE_CURRENT);
        double newSL = NormalizeDouble(currentPrice - stopLossPips, _Digits);

        if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && newSL > currentSL)
            trade.PositionModify(PositionGetTicket(i), newSL, PositionGetDouble(POSITION_TP));
        else if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && newSL < currentSL)
            trade.PositionModify(PositionGetTicket(i), newSL, PositionGetDouble(POSITION_TP));
    }
}

Códigos Bot MT5 Abiertos en Colombia: La Herramienta Perfecta para Traders

Los códigos de bots MT5 abiertos en Colombia representan una solución avanzada para traders que buscan maximizar la eficiencia en sus operaciones en MetaTrader 5. Estas herramientas automatizadas permiten optimizar estrategias de trading, ofreciendo flexibilidad y personalización para adaptarse a diversas necesidades del mercado financiero.

El trading automatizado con bots de código abierto proporciona a los traders la posibilidad de ajustar algoritmos según sus objetivos específicos. Ya sea que te dediques al trading intradía, a estrategias a largo plazo o a scalping, los códigos abiertos te permiten tener un control total sobre tu operativa.

Beneficios del Trading Automatizado

Entre los principales beneficios de utilizar bots MT5 de código abierto destaca su capacidad para ejecutar operaciones de forma rápida y precisa, minimizando errores humanos. Además, ofrecen la oportunidad de aprender y mejorar estrategias al analizar su comportamiento en tiempo real.

La accesibilidad también es un punto clave: al ser de código abierto, cualquier trader puede acceder, modificar y usar estas herramientas sin restricciones. Esto fomenta una comunidad de desarrollo activa y colaborativa, ideal para aquellos interesados en la innovación tecnológica dentro del trading.

Descubre el potencial de los códigos Bot MT5 abiertos y lleva tu trading al siguiente nivel.

¿Listo para automatizar tu trading?

Contáctanos para recibir asesoría personalizada sobre cómo implementar estos bots en tu cuenta de trading con un broker regulado.

¿Necesitas ayuda?