Having a problem compiling EA MQL5 code

 

I kindly need help with compiling mql5 code with 2 errors     '{' - unexpected end of program  on line: 85 column 5 and '{' - unbalanced parentheses  on line : 50 column 1. Any help


/+------------------------------------------------------------------+
//|                                                       RATTY4.mq5 |
//|                                     Copyright 2023,SMARTKENN FX. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
// Fibonacci retracement levels
input double Fibonacci38 = 0.382;
input double Fibonacci50 = 0.5;
input double Fibonacci61 = 0.618;

// RSI parameters
input int RsiPeriod = 14;

// MACD parameters
input int FastMA = 12;
input int SlowMA = 26;
input int SignalMA = 9;

// Stochastic parameters
input int StochasticK = 5;
input int StochasticD = 3;
input int StochasticSlow = 3;

// Risk management parameters
input double RiskPercent = 1.5;
input double LotSize = 0.01;
input int MaxTrades = 10;

// Magic number to identify trades opened by this EA
input int MagicNumber = 1234;

// Colors for buy and sell trades
color Buycolor = clrDodgerBlue;
color Sellcolor = clrTomato;

// Define variables for the display panel
int PanelHandle = 0;
string PanelName = "EA Panel";
datetime LastUpdate;
string LastTradeType;
double LastTradePrice;
double LastProfit;
double LastLoss;
double CurrentLotSize;
double StopLoss;
double TakeProfit;

// Define the OnTick function
void OnTick()
{
    // Check if there are too many open trades
    if (TotalTrades() >= MaxTrades)
    {
        return;
    }
    
    // Check if there is a major economic news release
    if (IsNewsTime())
    {
        return;
    }
    
    // Calculate the lot size based on the equity balance and risk percent
    double Lot = AccountBalance() * RiskPercent / 100 / 100000;
    CurrentLotSize = Lot;
    
    // Calculate the Fibonacci levels
    double Fib38 = iHigh(NULL, PERIOD_CURRENT, 0) - (iHigh(NULL, PERIOD_CURRENT, 0) - iLow(NULL, PERIOD_CURRENT, 0)) * Fibonacci38;
    double Fib50 = iHigh(NULL, PERIOD_CURRENT, 0) - (iHigh(NULL, PERIOD_CURRENT, 0) - iLow(NULL, PERIOD_CURRENT, 0)) * Fibonacci50;
    double Fib61 = iHigh(NULL, PERIOD_CURRENT, 0) - (iHigh(NULL, PERIOD_CURRENT, 0) - iLow(NULL, PERIOD_CURRENT, 0)) * Fibonacci61;
    
    // Calculate the RSI value
    double Rsi = iRSI(NULL, PERIOD_CURRENT, RsiPeriod, PRICE_CLOSE, 0);
    
    // Calculate the MACD values
    double MacdMain = iMACD(NULL, PERIOD_CURRENT, FastMA, SlowMA, SignalMA, PRICE_CLOSE, MODE_MAIN, 0);
    double MacdSignal = iMACD(NULL, PERIOD_CURRENT, FastMA, SlowMA, SignalMA, PRICE_CLOSE, MODE_SIGNAL, 0);
    
    // Calculate the Stochastic values
    double StochasticMain = iStochastic(NULL, PERIOD_CURRENT, StochasticK, StochasticD, StochasticSlow, MODE_SMA, 0, MODE_MAIN, 0);
    double StochasticSignal = iStochastic(NULL, PERIOD_CURRENT, StochasticK, StochasticD, StochasticSlow, MODE_SMA, 0, MODE_SIGNAL, 0);
    
    // Check for buy signal
    if (Rsi < 30 && MacdMain > MacdSignal && StochasticMain < 20 && iClose(NULL, PERIOD_CURRENT, 0) < Fib38)
    {
      
        // Open
 

You are using ChatGPT, right? Then please ask ChatGPT to fix it for you.

Obviously, if you are using an A.I. to produce your code, then clearly you don't know how to code in MQL.

So any advice we give you, you will not understand nor will you know how to implement.

ChatGPT produces the most horrible code. If you want something better, then please hire a human coder to do it properly.

 
  1. Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. ChatGPT (the worst), EA builder, EA Builder Pro, EATree, Etasoft forex generator, Forex Strategy Builder, ForexEAdvisor (aka. ForexEAdvisor STRATEGY BUILDER, and Online Forex Expert Advisor Generator), ForexRobotAcademy.com, forexsb, FX EA Builder, fxDreema, Forex Generator, FxPro, Molanis, Octa-FX Meta Editor, Strategy Builder FX, Strategy Quant, Visual Trader Studio, MQL5 Wizard, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.

    1. Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
      If we tell you what you need, you can't code it.
      If we give you the code, you don't know how to integrate it into yours.

      We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

    2. ChatGPT
      1. Mixing MT4 and MT5 code together.
      2. Creating multiple OnCalculate/OnTick functions.
      3. OnCalculate returning a double.
      4. Filling buffers with zero in OnInit (they have no size yet). Setting buffer elements to zero but not setting Empty Value to correspond.
      5. Calling undefined functions.
      6. Sometimes, not using strict (MT4 code).
      7. Code that will not compile.
      8. Creating code outside of functions.
      9. Creating incomplete code.
      10. Initialization of Global variables with non-constants.
      11. Assigning a MT5 handle to a double or missing the buffer and bar indexes in a MT4 call.
      12. Useing MT4 Trade Functions without first selecting an order.
      13. Even it says do not use it
                  for coding. (2023)
      EA builder
      1. Counting up while closing multiple orders.
      2. New bar code: Bars is unreliable (Max bars in chart), volume is unreliable (miss ticks.) Always use time.
      3. Not adjusting for 4/5 digit brokers, TP/SL and slippage.
      4. Not checking return codes.
      EATree Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)
      ForexEAdvisor
      1. Non-updateing global variables.
      2. Compilation errors.
      3. Not checking return codes.
      4. Not reporting errors.
      FX EA Builder
      1. Not checking return codes.
      2. Loosing open tickets on terminal restart. No recovery (crash/power failure.)
      3. Not adjusting stops for the spread.
      4. Using OrdersTotal directly.
 

Only problem is Chat GPT is only as good as you can prompt it : you'll have to learn to engineer your prompts correctly ,

dumb prompt dumb answer , its a tool for ideas

but the fact that you don't see your code is incomplete is the problem ,this means you don't know what its doing and therefore you yourself don't know how to fix it   Fernando Carreiro is correct it should fix it for you this will teach you how to prompt it to do what you require , but it is also worthy to note that it does not yet consider every aspect of mql5 library and the proper execution there of you could have worked past it feeding it the parameters in the prompted itself but you do not know what they are because you have the idea to make money.

but your lacking the right formula to obtain your goal thus your progress will be slow in this regard and nobody here is going to try and help as you have taken the easy way /this is shown by the fact that you did not realize that the code is incomplete to begin with .   

 
Fernando Carreiro #:

You are using ChatGPT, right? Then please ask ChatGPT to fix it for you.

Obviously, if you are using an A.I. to produce your code, then clearly you don't know how to code in MQL.

So any advice we give you, you will not understand nor will you know how to implement.

ChatGPT produces the most horrible code. If you want something better, then please hire a human coder to do it properly.

Thank you for your honest answer Mr Fernando

Reason: