Oil & Natural gas EA

Vengeance Seeker  
Hello everyone. I am seeking assistance on an EA that I have created that only trades Oil and Natural Gas. It trades on the 15M chart and takes trades from the HOD or LOD after  SPECIFIC candlestick formations. I have coded majority of it. Its nearly done but I've got 100 errors and 1 warning. I am new to this. I'm just seeking advise and assistance if possible. I've attached the file
Files:
MRNG_STAR1.mq5  20 kb
William Roeder  
Learn the language.
          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.

  1. This just declares that you will define a function taking five parameters and returning a bool.
    It has an extra comma.
    bool Buy(
       double             lot,
       string             symbol=NULL,
       double             price=0.0,
       double             StopLoss= 30,
       double             TakeProfit= 130,);
    This is how you define such a function.
    bool Buy(
       double             lot,
       string             symbol=NULL,
       double             price=0.0,
       double             StopLoss= 30,
       double             TakeProfit= 130)
    {
       // code that does things with those parameters
       return result;
    }

    You already know how to do that with your function MarketOrder.

  2.             if(true)
                  {
                   bool Buy()
                  }
    

    What is this nonsense? You have to call the function, with its parameters. Do something with the return value. And end the call with a semicolon.

  3. Where is the close brace for the enclosing function?

  4. int OnInit();
      def worktime;
      {
    //--- Check the time.
       if(TimeCurrent() >= StringToTime(TimeToString(TimeCurrent(),TIME_DATE)+" "+StartHour+":"+StartMinute) &&
           TimeCurrent()  < StringToTime(TimeToString(TimeCurrent(),TIME_DATE)+" "+EndHour+":"+EndMinute) );
         {
          Print("Grind!");
          return(TimeCurrent());
    

    Perhaps you should read the manual. OnInit returns an int. It does not return a datetime.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  5.   if(OrdersTotal()==0)
         {
          if(BuySignal) 
            OrderSend(Buy);

    Perhaps you should read the manual. OrderSend does not have one parameter and you can't pass a function. But you already know how to do that with your function MarketOrder.

  6.           OrderClose(All orders); 
    

    Perhaps you should read the manual. Learn how to select orders in an OrderSelect loop and close them one by one. Or perhaps you meant positions not pending orders.

  7. Did "you" write that with Chatgpt (the worst)?

    Chatgpt (the worst), EA builder, EA Builder Pro, EATree, Etasoft forex generator, Forex Strategy Builder, ForexEAdvisor, ForexRobotAcademy.com, forexsb, 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.
Vengeance Seeker  
William Roeder #:
Learn the language.
          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.

  1. This just declares that you will define a function taking five parameters and returning a bool.
    It has an extra comma.
    This is how you define such a function.

    You already know how to do that with your function MarketOrder.

  2. What is this nonsense? You have to call the function, with its parameters. Do something with the return value. And end the call with a semicolon.

  3. Where is the close brace for the enclosing function?

  4. Perhaps you should read the manual. OnInit returns an int. It does not return a datetime.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  5. Perhaps you should read the manual. OrderSend does not have one parameter and you can't pass a function. But you already know how to do that with your function MarketOrder.

  6. Perhaps you should read the manual. Learn how to select orders in an OrderSelect loop and close them one by one. Or perhaps you meant positions not pending orders.

  7. Did "you" write that with Chatgpt (the worst)?

    Chatgpt (the worst), EA builder, EA Builder Pro, EATree, Etasoft forex generator, Forex Strategy Builder, ForexEAdvisor, ForexRobotAcademy.com, forexsb, 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.
I coded on MetaEditor5 but i used different pieces of code from articles i found here on this site and on the forum then some is my own. Like I said I'm new to this. I'm better with python. But integrating python with MetaTrader5 was a mountain climb. So I was then advised to use MetaEditor and code in the mql native language. I just need someone to hold my hand throughout this entire EA build it will be easier to learn with someone assisting. I completed my degree in computer science last year so I know how to code. But this is different stuff
Fernando Carreiro  
Vengeance Seeker #: I coded on MetaEditor5 but i used different pieces of code from articles i found here on this site and on the forum then some is my own. Like I said I'm new to this. I'm better with python. But integrating python with MetaTrader5 was a mountain climb. So I was then advised to use MetaEditor and code in the mql native language. I just need someone to hold my hand throughout this entire EA build it will be easier to learn with someone assisting. I completed my degree in computer science last year so I know how to code. But this is different stuff

If you have a computer science degree, hopefully you learned C/C++. That is the knowledge you should draw on as MQL is very similar to C/C++.

However, the code you presented, does not seem to show you knowing C/C++ at all that well.

Vengeance Seeker  
Fernando Carreiro #:

If you have a computer science degree, hopefully you learned C/C++. That is the knowledge you should draw on as MQL is very similar to C/C++.

However, the code you presented, does not seem to show you knowing C/C++ at all that well.

I just coded a few if statements and literally edited pieces of code I found here on this site. Why i did that is because I've never coded an EA before. I've never used MetaEditor. And I need this EA completed ASAP!!!. My first option was to use VS Code and Jupyter which I'm used to. And that eventually got working with the terminal until someone on here basically told me I'm wasting my time with Python.
Fernando Carreiro  
Vengeance Seeker #: I just coded a few if statements and literally edited pieces of code I found here on this site. Why i did that is because I've never coded an EA before. I've never used MetaEditor. And I need this EA completed ASAP!!!. My first option was to use VS Code and Jupyter which I'm used to. And that eventually got working with the terminal until someone on here basically told me I'm wasting my time with Python.

Then forget the ASAP! That is not reasonable. If you want ASAP, hire someone to code it for you. Otherwise, throw away the ASAP and learn to code in MQL5 properly over an extended period of time.

Vengeance Seeker  
Fernando Carreiro #:

Then forget the ASAP! That is not reasonable. If you want ASAP, hire someone to code it for you. Otherwise, throw away the ASAP and learn to code in MQL5 properly over an extended period of time.

You're absolutely right. At this moment I've only got 2 options. I will learn to MQL5 while I raise money to hire someone. This wasn't the response I hoping for with this EA. Clearly I'll have to restart it or just scrap it completely. 
Fernando Carreiro  
Vengeance Seeker #: You're absolutely right. At this moment I've only got 2 options. I will learn to MQL5 while I raise money to hire someone. This wasn't the response I hoping for with this EA. Clearly I'll have to restart it or just scrap it completely. 

For someone who has a Computer Science degree, your original reasoning was not consistent with the objective.

You of all people, should know and understand the required learning curve for any computer language and its underlaying platform.

It should have been obvious from the start, that it would require some amount of time for you to become proficient at it.

Vengeance Seeker  
Fernando Carreiro #:

For someone who has a Computer Science degree, your original reasoning was not consistent with the objective.

You of all people, should know and understand the required learning curve for any computer language and its underlaying platform.

It should have been obvious from the start, that it would require some amount of time for you to become proficient at it.

I knew very well that it wasn't gonna be easy and quick. But I need this EA ASAP and I don't have money to pay someone. I've got no money at all. If you've ever done something with your problems being the biggest driving force then you'll understand. Reasoning sometimes goes out the window. But THANK YOU for knocking some sense back into me. I'm spending every chance and resource I have to learn MQL5 
Arpit T  
Vengeance Seeker #:
I knew very well that it wasn't gonna be easy and quick. But I need this EA ASAP and I don't have money to pay someone. I've got no money at all. If you've ever done something with your problems being the biggest driving force then you'll understand. Reasoning sometimes goes out the window. But THANK YOU for knocking some sense back into me. I'm spending every chance and resource I have to learn MQL5 

Did you get your computer science degree ASAP? As mentioned by Fernando, you can hire a freelancer since your problem is a "want" and not something which seems interesting

Fernando Carreiro  
Vengeance Seeker #: I knew very well that it wasn't gonna be easy and quick. But I need this EA ASAP and I don't have money to pay someone. I've got no money at all. If you've ever done something with your problems being the biggest driving force then you'll understand. Reasoning sometimes goes out the window. But THANK YOU for knocking some sense back into me. I'm spending every chance and resource I have to learn MQL5 

Then if you don't have the money for it, then it is not ASAP. For the simple fact, that having an EA does not mean it is going to be profitable in a very short term, and even if it was guaranteed to be profitable, you don't have the capital to invest. And even if you used a Prop-firm, their requirements are tough, and you would not meet those requirements with something you don't yet master.

Becoming consistently profitable at trading, even with EAs, requires many years. It's like any other profession—it takes time—a lot of time. Time is required to gain experience and with it the skill and the knowledge that it requires.

So, if you need money for life's requirements, focus on what you can already do well and from which you can directly benefit with little risk, even if it is not a lot.

Reason: