coding

 

Hi i try to make from one indicator to work as an AI all is well til this 2 things  i need some help 

first erorr is, ')' - unexpected end of program

 


secand erorr is, '{' - unbalanced parentheses



 
myke290103:

Hi i try to make from one indicator to work as an AI all is well til this 2 things  i need some help 

first erorr is, ')' - unexpected end of program

secand erorr is, '{' - unbalanced parentheses

Don't show screenshots of code.

If you need help with your code, then provide all relevant code as an attached file or use the CODE button (Alt-S) when inserting code in your post.

 
If you need help with your code, then provide all relevant code as an attached file or use the CODE button (Alt-S) when inserting code in your post. !!!!!
MQL5.community - User Memo
MQL5.community - User Memo
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
 
myke290103 #: here is all code 

Please edit your post and insert your code properly without all that extra white-space on every second line.

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
//+------------------------------------------------------------------+
//|                                      PricePosition_Corrected.mq4 |
//|                       Copyright 2023, [Your Name]                  |
//+------------------------------------------------------------------+
#property copyright "[Your Name]"
#property version   "1.00"
#property strict

// Define the 'corner' enum
enum corner
{
    RightHand = 1,
    LeftHand = 0
};

// Define the 'YN' enum
enum YN
{
    Yes = 1,
    No = 0
};

// Define the input variables
input corner cor = RightHand;
input YN UseAlert = Yes;
input color BuyColor = clrAqua;
input color SellColor = clrOrangeRed;
input color clrNT = clrYellow;

// Declare the indicator buffers
double angle[];
double signal[];
double media1[];
double media2[];

// Define the day of the week
string day[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int xdis = 0;
int ydis = 135;

color clrfont;

int cal;
int pal;
int prc;
int pdn;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
    // Indicator buffers mapping
    IndicatorBuffers(4);
    SetIndexBuffer(0, angle);
    SetIndexBuffer(1, signal);
    SetIndexBuffer(2, media1);
    SetIndexBuffer(3, media2);

    SetIndexStyle(0, DRAW_SECTION, STYLE_SOLID);
    SetIndexStyle(1, DRAW_NONE);
    SetIndexStyle(2, DRAW_NONE);
    SetIndexStyle(3, DRAW_NONE);

    SetIndexLabel(0, "Turn");
    SetIndexLabel(1, NULL);
    SetIndexLabel(2, NULL);
    SetIndexLabel(3, NULL);

    IndicatorShortName("PricePosition");

    xdis = cor == 1 ? 133 : 30;

    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    ObjectsDeleteAll();
    GlobalVariablesDeleteAll();
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
    int i, limit;
    limit = rates_total - prev_calculated;
    if (prev_calculated > 0)
    {
        limit++;
    }

    ArraySetAsSeries(angle, true);
    ArraySetAsSeries(signal, true);
    ArraySetAsSeries(media1, true);
    ArraySetAsSeries(media2, true);
    ArraySetAsSeries(open, true);
    ArraySetAsSeries(high, true);
    ArraySetAsSeries(low, true);
    ArraySetAsSeries(close, true);

    for (i = limit - 1; i >= 0; i--)
    {
        media1[i] = iMA(_Symbol, 0, 26, 0, 2, 4, i);
        media2[i] = iMA(_Symbol, 0, 20, 0, 0, 4, i);
        signal[i] = (media1[i] + media2[i]) / 2;
    }

    for (i = limit - 1; i >= 0; i--)
    {
        if ((open[i] <= signal[i]) && (close[i] >= signal[i]))
            angle[i] = low[i];
        else if ((open[i] >= signal[i]) && (close[i] <= signal[i]))
            angle[i] = high[i];
        else
            angle[i] = EMPTY_VALUE;
    }

    double priceturn = 0.0;
    int seek = 0;
    int s = 0;

    while (seek < 1)
    {
        if (angle[s] != EMPTY_VALUE)
        {
            priceturn = angle[s];
            seek++;
        }
        s++;
    }

    if (close[0] > priceturn)
    {
        CreateLabel(0, "AngleDirection", "BUY", "Verdana", 28, BuyColor, cor, xdis, ydis);
        CreateLabel(0, "AngleLevel", "above " + DoubleToString(priceturn, _Digits), "Verdana", 10, BuyColor, cor, xdis, ydis + 45);

        clrfont = BuyColor;
        cal = 1;

        if ((cal != pal) && (UseAlert == 1))
        {
            Alert("*" + WindowExpert
 
myke290103 #:

Is this ChatGPT generated code?

It looks like it, because it is incomplete.

Do you know how to code?

 
Fernando Carreiro #:

Is this ChatGPT generated code?

It looks like it, because it is incomplete.

Do you know how to code?

yes it is can you fix it ?
 
myke290103 #: yes it is can you fix it ?

Please, don't request help for ChatGPT (or other A.I.) generated code. It generates horrible code.

Please use the Freelance section for such requests — https://www.mql5.com/en/job

 
myke290103 #: yes it is can you fix it ?
  1. Stop using ChatGPT.
              Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)

    ChatGPT (the worst), “Bots Builder”, “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.

    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.

    ChatGPT
    1. Even it says do not use it for coding. * 
    2. Mixing MT4 and MT5 code together.
    3. Creating multiple OnCalculate/OnTick functions.
    4. OnCalculate returning a double.
    5. Filling buffers with zero in OnInit (they have no size yet). Setting buffer elements to zero but not setting Empty Value to correspond.
    6. Calling undefined functions.
    7. Calling MT4 functions in MT5 code.
    8. Sometimes, not using strict (MT4 code).
    9. Code that will not compile.
    10. Creating code outside of functions. * 
    11. Creating incomplete code. * 
    12. Initialization of Global variables with non-constants. * 
    13. Assigning a MT5 handle to a double or missing the buffer and bar indexes in a MT4 call. * 
    14. Useing MT4 Trade Functions without first selecting an order. * 
    15. Uses NULL in OrderSend. * 
    bot builder Creating two OnInit() functions. * 
    EA builder
    1. Counting up while closing multiple orders.
    2. Not useing time in new bar detection.
    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.
    5. Using the old event handlers.

  2. You have only four choices:

    1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

    2. Try asking at:

    3. MT4: Learn to code it.
      MT5: Begin learning to code it.

      If you don't learn MQL4/5, 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 your code.
                I need HEEEELP, please, it's URGENT...really ! - General - MQL5 programming forum (2017)

    4. Or pay (Freelance) someone to code it. Top of every page is the link Freelance.
                Hiring to write script - General - MQL5 programming forum (2019)

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
              No free help (2017)