Correção de EA basedo em MAXD Intradey

MQL5 Uzmanlar Forex

İş tamamlandı

Tamamlanma süresi: 17 saat
Geliştirici tarafından geri bildirim
Cliente muito compreensivo :), espero ter mais negócios com ele!
Müşteri tarafından geri bildirim
Desenvolvedor rápido atencioso muito educado. com certeza recomendo a toda comunidade.

Şartname

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.

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(50)
Projeler
51
8%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
2
Geliştirici 2
Derecelendirme
(574)
Projeler
945
47%
Arabuluculuk
309
58% / 27%
Süresi dolmuş
125
13%
Serbest
3
Geliştirici 3
Derecelendirme
(153)
Projeler
240
34%
Arabuluculuk
20
45% / 30%
Süresi dolmuş
3
1%
Serbest
4
Geliştirici 4
Derecelendirme
(47)
Projeler
79
11%
Arabuluculuk
4
25% / 75%
Süresi dolmuş
2
3%
Serbest
5
Geliştirici 5
Derecelendirme
(11)
Projeler
17
59%
Arabuluculuk
2
0% / 100%
Süresi dolmuş
2
12%
Serbest
6
Geliştirici 6
Derecelendirme
(6)
Projeler
7
14%
Arabuluculuk
1
100% / 0%
Süresi dolmuş
0
Serbest
Yayınlandı: 1 kod
7
Geliştirici 7
Derecelendirme
(298)
Projeler
478
40%
Arabuluculuk
105
40% / 24%
Süresi dolmuş
82
17%
Yüklendi
Yayınlandı: 2 kod
Benzer siparişler
Vamos aprender a operar no mercado Forex vamos aprender vamos trabalhar no mercado Forex vamos temos tudo para dar certo só trabalho só com trabalho podemos fazer tudo para nossa vida

Proje bilgisi

Bütçe
30+ USD