basic error, but it's not the same thing (line 80) ';' - open parenthesis expected

 

 //+------------------------------------------------------------------+
//|                                              LinearRegressionEA.mq5|
//|                    Copyright 2024, MetaQuotes Software Corp.      |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2024, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

// Incluindo o arquivo de inclusão para ter acesso às constantes de negociação
#include <Trade\Trade.mqh>

// Variáveis globais
double upper[], lower[], middle[];
string symbolName;

// Entradas do usuário
input int    period = 14; // Período do canal de regressão linear
input double lotSize = 0.1; // Tamanho do lote para operações
input double stopLossMultiplier = 2.0; // Multiplicador do stop loss em relação à distância do canal
input double stopLoss = 100; // Stop Loss em pontos

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    // Inicialização bem-sucedida
    symbolName = Symbol();
    return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    // Função de finalização
}
//+------------------------------------------------------------------+
//| Expert tick function                                            |
//+------------------------------------------------------------------+
void OnTick()
{
    int copied = 0;

    // Calcular o canal de regressão linear
    copied = CopyBuffer(0, 0, 0, period, upper);
    copied = CopyBuffer(1, 0, 0, period, lower);
    copied = CopyBuffer(2, 0, 0, period, middle);

    // Obter o preço de fechamento do candle anterior e atual
    double prevClose = iClose(symbolName, Period(), 1);
    double currentClose = iClose(symbolName, Period(), 0);

    // Condição de venda
    if (prevClose > upper[1] && currentClose < upper[0])
    {
        // Executar a venda
        Sell();
    }

    // Condição de compra
    if (prevClose < lower[1] && currentClose > lower[0])
    {
        // Executar a compra
        Buy();
    }
}
//+------------------------------------------------------------------+
//| Função para executar uma ordem de venda                          |
//+------------------------------------------------------------------+
void Sell()
{
    // Verificar se não há nenhuma ordem aberta
    if (OrdersTotal() == 0)
    {
        // Calcular o stop loss
        double distance = middle[0] - upper[0];
        double sl = SymbolInfoDouble(symbolName, SYMBOL_BID) + stopLossMultiplier * distance * Point;

        // Enviar uma ordem de venda
        double price = SymbolInfoDouble(symbolName, SYMBOL_BID);
        double tp = middle[0];
        int ticket = OrderSend(symbolName, OP_SELL, lotSize, price, 3, sl, tp, "", 0, 0, clrRed);
        if (ticket > 0)
        {
            Print("Ordem de venda enviada com sucesso. Ticket: ", ticket);
        }
        else
        {
            Print("Erro ao enviar ordem de venda. Código do erro: ", GetLastError());
        }
    }
}
//+------------------------------------------------------------------+
//| Função para executar uma ordem de compra                         |
//+------------------------------------------------------------------+
void Buy()
{
    // Verificar se não há nenhuma ordem aberta
    if (OrdersTotal() == 0)
    {
        // Calcular o stop loss
        double distance = lower[0] - middle[0];
        double sl = SymbolInfoDouble(symbolName, SYMBOL_ASK) - stopLossMultiplier * distance * Point;

        // Enviar uma ordem de compra
        double price = SymbolInfoDouble(symbolName, SYMBOL_ASK);
        double tp = middle[0];
        int ticket = OrderSend(symbolName, OP_BUY, lotSize, price, 3, sl, tp, "", 0, 0, clrGreen);
        if (ticket > 0)
        {
            Print("Ordem de compra enviada com sucesso. Ticket: ", ticket);
        }
        else
        {
            Print("Erro ao enviar ordem de compra. Código do erro: ", GetLastError());
        }
    }
}
//+------------------------------------------------------------------+

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 599.00 USD
  • 2024.04.27
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Files:
Screenshot_8.jpg  254 kb
 
I guess your Point; is either _Point; or Point();
 
Carl Schreiber #:
I guess your Point; is either _Point; or Point();

It worked, but this operation selection error persists



 
Carl Schreiber #:
I guess your Point; is either _Point; or Point();
<Improperly formatted code removed by moderator>
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 599.00 USD
  • 2024.04.29
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

You used ChatGPT to make this, right? When you do this, you spend more time finding bugs than actually learning/writing correct code.


Take a look at the OrderSend documentation and note that the parameters you're passing are actually incorrect - it expects only two arguments, that is, a MqlTradeRequest and a MqlTradeResult structure.


If you have no expertise with the language, I suggest you to read the algo book. If you already do know some of the functions/syntax, you can skip to the creating an EA section.

Documentation on MQL5: Trade Functions / OrderSend
Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
The OrderSend() function is used for executing trade operations by sending requests to a trade server. Parameters request [in]  Pointer to a...
Reason: