Unexpected end of program 76 28 and unbalanced parentheses 31 1

 

Hey guys,


I'm a total noob trying to use AI to build this. Can anyone help me out with these errors the AI cannot figure out the issue.


thanks for help


//+------------------------------------------------------------------+
//|                                                          HWG.mq5 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
input string tickers = "/ES,/NQ,"; // Comma-separated list of ticker symbols
input int fast_ma_length = 5; // Fast MA Length
input int slow_ma_length = 20; // Slow MA Length
input double risk_reward_ratio = 3.0; // Risk/Reward Ratio
input int atr_period = 14; // ATR Period
input int higher_tf_ma_length = 50; // Higher Timeframe Moving Average Length
input double atr_multiplier = 2.0; // ATR Multiplier for Trailing Stop

double fast_ma, slow_ma, higher_tf_ma;
double atr;

// Initialization function
int OnInit()
{
    return(INIT_SUCCEEDED);
}

// Main function
void OnTick()
{
    // Iterate over tickers
    string symbol;
    string_list_to_array(tickers, symbol);
    for (int i = 0; i < ArraySize(symbol); i++)
    {
        // Set up moving averages
        fast_ma = iMA(symbol[i], 0, fast_ma_length, 0, MODE_EMA, PRICE_CLOSE, 0);
        slow_ma = iMA(symbol[i], 0, slow_ma_length, 0, MODE_EMA, PRICE_CLOSE, 0);
        higher_tf_ma = iMA(symbol[i], 0, higher_tf_ma_length, 0, MODE_EMA, PRICE_CLOSE, 0);

        // Set up ATR
        atr = iATR(symbol[i], 0, atr_period);

        // Determine trend direction
        bool higher_tf_trend = (SymbolInfoDouble(symbol[i], SYMBOL_LAST) > higher_tf_ma);
        bool long = (fast_ma > slow_ma) && higher_tf_trend;
        bool short = (fast_ma < slow_ma) && !higher_tf_trend;

        // Only take trades in the direction of the higher timeframe trend
        if(!higher_tf_trend){
            return;
        }

        // Calculate position size based on ATR and risk/reward ratio
        double position_size = AccountInfoDouble(ACCOUNT_BALANCE) * 0.01;
        double stop_loss = atr;
        double target_profit = atr * risk_reward_ratio;
        double atr_trailing_stop = atr * atr_multiplier;
        int slippage = 3;
        int magic_number = 12345;

        // Enter long trade with trailing stop loss
        if (long && !short)
        {
            double long_entry = SymbolInfoDouble(symbol[i], SYMBOL_ASK);
            double long_stop_loss = long_entry - stop_loss * _Point;
            double long_target_profit = long_entry + target_profit * _Point;
            double long_trailing_stop = long_entry - atr_trailing_stop * _Point;

            OrderSend(symbol[i], OP_BUY, position_size, long_entry, slippage, long_stop_loss, long_target_profit, "Long", magic_number, 0, Green);
            while (OrderSelect(0, SELECT_BY_POS, MODE_TRADES))
            {
                if (OrderMagicNumber() == magic_number)
                {
                    double long_tr
 

Please stop using ChatGPT or any other code generator.

They produce code so bad that it is often impossible to fix, needing it to be rewritten from scratch.

Not to mention that with any advice we give you, you will not be able to understand nor apply to the code, since you don’t know how to code.

Either learn to code properly yourself or hire someone to code it for you.

 
Matthew McClorey:

Hey guys,


I'm a total noob trying to use AI to build this. Can anyone help me out with these errors the AI cannot figure out the issue.


thanks for help


Looks like MQL4 merged with MQL5… No good 
 
Matthew McClorey:

Hey guys,


I'm a total noob trying to use AI to build this. Can anyone help me out with these errors the AI cannot figure out the issue.


thanks for help


As said don't use ChatGP. It typically merges er.g. MT4 and MT5.

You're better off with this:
Bear in mind there's virtually nothing that hasn't already been programmed for MT4/MT5 and is ready for you - so searching gives better results than AI or ChatGPT!

Quickstart for newbies: https://www.mql5.com/en/articles/496

and: https://www.mql5.com/en/articles/100
cookbook: https://www.mql5.com/en/search#!keyword=cookbook

Quick Start: Short Guide for Beginners
Quick Start: Short Guide for Beginners
  • www.mql5.com
Hello dear reader! In this article, I will try to explain and show you how you can easily and quickly get the hang of the principles of creating Expert Advisors, working with indicators, etc. It is beginner-oriented and will not feature any difficult or abstruse examples.