Need program help (midnight open line)

 
I asked Chatgpt to generate code for a midnight open line - a few errors and warnings popped up can anyone help me out? Hopefully I posted this correctly, sorry again if I did not.
Files:
 
TheSMTG: I asked Chatgpt to generate code for a midnight open line - a few errors and warnings popped up can anyone help me out? Hopefully I posted this correctly, sorry again if I did not.

We cannot help you with generated code. If you don't know how to code yourself, how are you to understand and implement any advice we give you?

Have your code generated by a human, not a machine, or take some time to learn to code yourself.

EDIT: By the way, the generated code is mostly MQL4 and will not work on MQL5.

 
TheSMTG: I asked Chatgpt to generate code for a midnight open line
  1. You got what you paid for.

    EA builder, EA Builder Pro, EATree, Etasoft forex generator, Forex Strategy Builder, ForexEAdvisor, ForexRobotAcademy.com, FX EA Builder, fxDreema, Forex Generator, FxPro, Molanis, Octa-FX Meta Editor, Online Forex Expert Advisor Generator, 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. EA builder makes bad code:
      1. Counting up while closing multiple orders.
      2. 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 adjusting for ECN brokers. pre-Build 500)
      5. Not checking return codes.
      EATree
      uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)
      FX EA Builder makes bad code:
      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.
      FOREXEADVISOR STRATEGY BUILDER makes bad code:
      1. Non-updateing global variables.
      2. Compilation errors.
      3. Not checking return codes.
      ForexEAdvisor makes bad code:
      1. Not checking return codes.
      2. Not reporting errors.

    Learn to code it, or pay someone (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum #1 (2019)

  2.    for (int i = 0; i < rates_total; i++)
       {
          if (time[i] >= TimeCurrent() - TimeDay() && time[i] < TimeCurrent())
          {
             MidnightOpenLine[i] = open[i];
          }
          else
          {
             MidnightOpenLine[i] = EMPTY_VALUE;
          }
       }

    MT5 does not have TimeDay(). Why did you post your MT4 question in the MT5 Indicators section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  3. Buffers are as-series. The arrays in OnCalculate are not.

    To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

  4. Substracting a few seconds (TimeDay) off of TimeCurrent is meaniingless. You want to see if the bar is the first of that day; nothing to do with current time.
              Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017)

  5. You are drawing a line. That is visiable when you draw from one bar to another; you don't. You wanted a vertical line.

  6. Why are you redrawing all bars each tick?
              How to do your lookbacks correctly #9#14 & #19 (2016)

Reason: