Beginners Help, please...

 

Hi guys,

Im not a programmer, but just tried to write a code using chatgpt and it works a bit, but the part of the code that I want to show me a display info, keeps showing me some errors...

Can someone please help me?

Im posting the code of this part here.... it keeps showing me part of this code in one horizontal line, but what It should supposed to show is on the top, left side of the chart all these info in the vertical, with each info in one line vertically...


Thanks for all your time reading this topic...


//+-----------------------------------------+

//| Exibe o painel de informações no gráfico |

//| Display information panel on chart       |

//+-----------------------------------------+

void DisplayInfoPanel()

  {

   string info = StringFormat(

      "OrderCloser v1.0\n"

      "Modo: %s\n"

      "Ordens Fechadas: %d\n"

      "Lucro Diário Usado: %.2f\n"

      "Lucro Diário: %.2f\n"

      "Lucro Disponível: %.2f\n"

      "Critério de Fechamento: %d\n"

      "Tempo Médio de Fechamento: %.2f segundos\n"

      "Desenvolvedor: mql5@gmail.com\n"

      "Website: https://www.mql5.com",

      activeMode ? "Ativo" : "Observação",

      closedOrdersCount,

      usedProfit,

      dailyProfit,

      CalculateAvailableProfit(),

      CloseCriteria,

      CalculateAverageCloseTime());



   // Define as propriedades de exibição do texto / Set text display properties

   int fontSize = FontSize;

   color fontColor = clrWhite;

   int xPos = 10;

   int yPos = 10;



   // Remove o objeto existente antes de criar um novo / Remove existing object before creating a new one

   ObjectDelete("InfoPanel");



   // Cria o objeto de texto / Create the text object

   ObjectCreate(0, "InfoPanel", OBJ_LABEL, 0, 0, 0);

   ObjectSetInteger(0, "InfoPanel", OBJPROP_XDISTANCE, xPos);

   ObjectSetInteger(0, "InfoPanel", OBJPROP_YDISTANCE, yPos);

   ObjectSetInteger(0, "InfoPanel", OBJPROP_CORNER, CORNER_LEFT_UPPER);

   ObjectSetInteger(0, "InfoPanel", OBJPROP_FONTSIZE, fontSize);

   ObjectSetInteger(0, "InfoPanel", OBJPROP_COLOR, fontColor);

   ObjectSetString(0, "InfoPanel", OBJPROP_TEXT, info);

  }


Art.In.Box
  • artinbox.shop
"Discover authentic vintage Japanese collectibles at our online store. Explore rare Bandai Charawheels mini cars, Chucky memorabilia, Konami mini cars, and more."
 

When you post code please use the CODE button (Alt-S)!

Use the CODE button

 

don't do this

ObjectDelete( "InfoPanel");

because it's bad code... you should use ObjectFind instead to see if it already exists

neither is this correct as it should be

ObjectDelete(0, "InfoPanel");


Sorry but any non-programmer who uses chatGPT to do all the work is frowned upon, rightly so, and it will give you bad code.


You can't use \n to make a new margin with Objects. For that to work you will use the Comment() function...


You have to change the Y value for every new label.

int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
DisplayInfoPanel();
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


//+-----------------------------------------+

//| Exibe o painel de informações no gráfico |

//| Display information panel on chart       |

//+-----------------------------------------+

void DisplayInfoPanel(){
  
  string info_1 = "aaaaaaaaa";
  string info_2 = "bbbbbbbbb";
  string info_3 = "ccccccccc";
  
  makeLabel(10, 10, CORNER_LEFT_UPPER, 8, clrWhite, info_1, 0);
  makeLabel(10, 20, CORNER_LEFT_UPPER, 8, clrWhite, info_2, 1);
  makeLabel(10, 30, CORNER_LEFT_UPPER, 8, clrWhite, info_3, 2);



}
  
  
  
void makeLabel(int xPos, int yPos, ENUM_BASE_CORNER corner, int fontSize, color fontColor, string info, int index)
{

    if (ObjectFind(0, "InfoPanel" + IntegerToString(index)) < 0){
    
        //If the object does not exist, create it
        ObjectCreate(0, "InfoPanel" + IntegerToString(index), OBJ_LABEL, 0, 0, 0);
    }
    
    // Set properties of the label object
    ObjectSetInteger(0, "InfoPanel" + IntegerToString(index), OBJPROP_XDISTANCE, xPos);
    ObjectSetInteger(0, "InfoPanel" + IntegerToString(index), OBJPROP_YDISTANCE, yPos);
    ObjectSetInteger(0, "InfoPanel" + IntegerToString(index), OBJPROP_CORNER, corner);
    ObjectSetInteger(0, "InfoPanel" + IntegerToString(index), OBJPROP_FONTSIZE, fontSize);
    ObjectSetInteger(0, "InfoPanel" + IntegerToString(index), OBJPROP_COLOR, fontColor);
    ObjectSetString(0, "InfoPanel" + IntegerToString(index), OBJPROP_TEXT, info);
}


// delete the objects when you remove the indicator
void OnDeinit(const int reason){

   ObjectsDeleteAll(0, "InfoPanel");
   
}
 
Esassaki2611: Im not a programmer, but just tried to write a code using chatgpt

Stop using ChatGPT/Copilot.
          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, “LP-MOBI”, 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.
 
Esassaki2611:

Hi guys,

Im not a programmer, but just tried to write a code using chatgpt and it works a bit, but the part of the code that I want to show me a display info, keeps showing me some errors...

Can someone please help me?

Im posting the code of this part here.... it keeps showing me part of this code in one horizontal line, but what It should supposed to show is on the top, left side of the chart all these info in the vertical, with each info in one line vertically...


Thanks for all your time reading this topic...



You are not a programmer. And you want the code fixed. hire a programmer.

MQL5 is complex.

And programmers don't work for free, as well as ChatGPT4o...

So, choose one...

 
Conor Mcnamara #:

Thank you for your time and answer...

Conor Mcnamara #:

don't do this

because it's bad code... you should use ObjectFind instead to see if it already exists

neither is this correct as it should be


Sorry but any non-programmer who uses chatGPT to do all the work is frowned upon, rightly so, and it will give you bad code.


You can't use \n to make a new margin with Objects. For that to work you will use the Comment() function...


You have to change the Y value for every new label.

 
Flavio Javier Jarabeck #:

You are not a programmer. And you want the code fixed. hire a programmer.

MQL5 is complex.

And programmers don't work for free, as well as ChatGPT4o...

So, choose one...

  Dude, I appreciate your answer and all my respect to all programmers that at least has the patience to kindly let me know that chatgpt and others IAs are not so good for  beginners  like me, and you dont have to tell what I should do... and dont blame ppl that want at least give an answer for free and not say what you are saying me...

That looks like a cheap programmer that wants  some money just to give an answer...

Have a good day man !

 
William Roeder #:

Stop using ChatGPT/Copilot.
          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, “LP-MOBI”, 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.
Thanks for your answer and time to let me know these info man, have a good day !
 
Yes William is very right here. It will save you time to learn so that you can get things coded easily and efficiently, and there is no mistake in learning to code, it can only be good for you.