Correção de EA basedo em MAXD Intradey

MQL5 Experts Forex

Trabalho concluído

Tempo de execução 17 horas
Comentário do cliente
Desenvolvedor rápido atencioso muito educado. com certeza recomendo a toda comunidade.
Comentário do desenvolvedor
Cliente muito compreensivo :), espero ter mais negócios com ele!

Termos de Referência

Olá, eu preciso de um desenvolvedor experiente em MQL5 para corrigir um código de Expert Advisor que está com erros de compilação. O código é para uma estratégia baseada no indicador MACD e tem parâmetros de risco definidos pelo usuário. O código está anexado a este pedido. Por favor, me diga quanto tempo e quanto custa para fazer esse trabalho.

#define MagicNumber 12345
//---
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\AccountInfo.mqh>


// Parâmetros de entrada
input int MagicNumber = 12345;  // Número mágico para identificar as operações do robô
input double RiskPercentage = 1.0;  // Percentual de risco por operação (1.0 = 1%)
input int StopLoss = 20;  // Valor do stop-loss em pips
input int TakeProfit = 30;  // Valor do take-profit em pips


// Função de inicialização do robô
int OnInit()
{
    // Definir o risco por operação com base no saldo da conta
    double AccountBalance = AccountBalance();
    double RiskAmount = AccountBalance * RiskPercentage / 100.0;
    double OneLotValue = MarketInfo(Symbol(), MODE_TICKVALUE);

    // Definir o tamanho do lote com base no risco por operação e no valor de um lote
    double LotSize = RiskAmount / (OneLotValue * StopLoss);

    // Definir as configurações do risco
    SetRiskParameters(Symbol(), StopLoss, TakeProfit, LotSize);

    return (INIT_SUCCEEDED);
}

// Função para abrir uma posição de compra
void BuySignal()
{
    // Verificar se não há nenhuma posição aberta
    if (PositionsTotal() == 0)
    {
        // Gerar sinal de compra do MACD
        if (iMACD(Symbol(), 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1) > iMACD(Symbol(), 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1))
        {
            // Calcular o tamanho do lote com base no risco por operação
            double LotSize = GetRiskLotSize(Symbol());

            // Abrir uma posição de compra
            int ticket = OrderSend(Symbol(), OP_BUY, LotSize, Ask, 3, Bid - StopLoss * Point, Bid + TakeProfit * Point, "Buy", MagicNumber, 0, Blue);
        }
    }
}

// Função para abrir uma posição de venda
void SellSignal()
{
    // Verificar se não há nenhuma posição aberta
    if (PositionsTotal() == 0)
    {
        // Gerar sinal de venda do MACD
        if (iMACD(Symbol(), 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1) < iMACD(Symbol(), 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1))
        {
            // Calcular o tamanho do lote com base no risco por operação
            double LotSize = GetRiskLotSize(Symbol());

            // Abrir uma posição de venda
            int ticket = OrderSend(Symbol(), OP_SELL, LotSize, Bid, 3, Ask + StopLoss * Point, Ask - TakeProfit * Point, "Sell", MagicNumber, 0, Red);
        }
    }
}

// Função para gerenciar o risco da posição
void SetRiskParameters(string symbol, int stopLoss, int takeProfit, double lotSize)
{
    // Definir as configurações de stop-loss e take-profit
    int slippage = MarketInfo(symbol, MODE_SPREAD) + StopLevel * Point;
    double stopLossPrice = stopLoss * Point;
    double takeProfitPrice = takeProfit * Point;

    // Definir as configurações de risco para a posição atual
    for (int i = 0; i < OrdersTotal(); i++)
    {
        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
            if (OrderSymbol() == symbol && OrderMagicNumber() == MagicNumber)
            {
                if (OrderType() == OP_BUY)
                {
                    OrderModify(OrderTicket(), OrderOpenPrice(), stopLossPrice, takeProfitPrice, 0, Blue);
                }
                else if (OrderType() == OP_SELL)
                {
                    OrderModify(OrderTicket(), OrderOpenPrice(), stopLossPrice, takeProfitPrice, 0, Red);
                }
            }
        }
    }
}

// Função para calcular o tamanho do lote com base no risco por operação
double GetRiskLotSize(string symbol)
{
    double AccountBalance = AccountBalance();
    double RiskAmount = AccountBalance * RiskPercentage / 100.0;
    double OneLotValue = MarketInfo(symbol, MODE_TICKVALUE);
    double LotSize = RiskAmount / (OneLotValue * StopLoss);
    return LotSize;
}

// Função de execução contínua do robô
void OnTick()
{
    // Verificar os sinais de entrada
    BuySignal();
    SellSignal();
}

// Função de encerramento do robô
void OnDeinit(const int reason)
{
    // Encerrar todas as posições abertas
    for (int i = PositionsTotal() - 1; i >= 0; i--)
    {
        if (PositionSelectByTicket(PositionGetTicket(i)))
        {
            if (PositionMagicNumber() == MagicNumber)
            {
                OrderClose(PositionGetTicket(i), PositionGetDouble(POSITION_VOLUME), PositionGetDouble(POSITION_CLOSE), 3, Violet);
            }
        }
    }
}


Obrigado.

Respondido

1
Desenvolvedor 1
Classificação
(50)
Projetos
51
8%
Arbitragem
0
Expirado
0
Livre
2
Desenvolvedor 2
Classificação
(574)
Projetos
945
47%
Arbitragem
309
58% / 27%
Expirado
125
13%
Livre
3
Desenvolvedor 3
Classificação
(153)
Projetos
241
34%
Arbitragem
21
48% / 29%
Expirado
3
1%
Livre
4
Desenvolvedor 4
Classificação
(47)
Projetos
79
11%
Arbitragem
4
25% / 75%
Expirado
2
3%
Livre
5
Desenvolvedor 5
Classificação
(11)
Projetos
17
59%
Arbitragem
2
0% / 100%
Expirado
2
12%
Livre
6
Desenvolvedor 6
Classificação
(6)
Projetos
7
14%
Arbitragem
1
100% / 0%
Expirado
0
Livre
Publicou: 1 código
7
Desenvolvedor 7
Classificação
(298)
Projetos
478
40%
Arbitragem
105
40% / 24%
Expirado
82
17%
Carregado
Publicou: 2 códigos
Pedidos semelhantes
Quero criar uma automação com minha identidade visual e que seja algo minimamente rentável…. Pq quero criar conteúdo e entregar o robo para meus alunos, Precisa ser algo principalmente com o ativo Xauusd, Quero ver Projetos e ideias tbm… porem minha ideia é ter algo automático mesmo pros futuros alunos
I need an indicator with strategys that wil help me with my LOW RRR trades (0.06:1, 0.1:1, 0.2:1) that i make every single day AND I DONT WANT to hear that Low RRR is risky. lesgo: 1- I will be utilizing this indicator every single day, and i will make up to 2 trades of this low rrr a day. I need a person that really knows what strategy fit most on the low rrr indicator. 2- I will open up to 10 diferent charts of

Informações sobre o projeto

Orçamento
30+ USD