My script successfully compiles without any errors but won't submit a trade in the strategy tester, and my print function doesn't return a value. - page 2

 
Fernando Carreiro #:

This is a messy mixture of MQL5 and MQL4 code. It certainly looks like horribly generated code.

Did I not say not to ask for help with A.I. generated code?

It is a total mess. It cannot be fixed. It has to be properly written from scratch.

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

What elements of it are MQL4 in your opinion? I did follow instructions from a tutorial from Rene Balke, "Master MQL5 Programming (Complete all in one guide)" on YouTube.
 
Colin Kimble #:
What elements of it are MQL4 in your opinion? I did follow instructions from a tutorial from Rene Balke, "Master MQL5 Programming (Complete all in one guide)" on YouTube.

Here are a few examples of a complete mix of MQL4, MQL5, and others that make no logical sense ...

// This is the calculations for the moving averages for the 0 index (daily time frame)
   if(iMA(NULL,PERIOD_CURRENT,10,0,MODE_SMA,iClose(NULL,PERIOD_CURRENT,1)) < iOpen(NULL,PERIOD_CURRENT,0))
if(iRSI(NULL,PERIOD_CURRENT,14,iClose(NULL,PERIOD_CURRENT,1)) > iRSI(NULL,PERIOD_CURRENT,14,iClose(NULL,PERIOD_CURRENT,2)))
if(iMomentum(NULL,PERIOD_CURRENT,10,iClose(NULL,PERIOD_CURRENT,1)) > iMomentum(NULL,PERIOD_CURRENT,10,iClose(NULL,PERIOD_CURRENT,2)))

All of the i???() Indicator functions in MQL5 return Indicator handles that should then be used with CopyBuffer(). They do not return buffer values directly as they do in MQL4.

Please refer to the MQL5 documentation of these Technical Indicator functions. I highly recommend you also read the MQL5 programming for traders - Book on MQL5.com

MQL5 programming for traders - Book on MQL5.com
MQL5 programming for traders - Book on MQL5.com
  • www.mql5.com
Modern trading relies heavily on computer technology. Automation now extends beyond the boundaries of exchanges and brokerage offices, becoming...
 
Colin Kimble #:
What elements of it are MQL4 in your opinion? I did follow instructions from a tutorial from Rene Balke, "Master MQL5 Programming (Complete all in one guide)" on YouTube.

you're very lucky to get, even that response from a moderator -- HAHAHA

...and if you learnt to code that from someone, then, that trainer does not know more about coding than you do; OR, you did not listen and watch very much; and need to go watch the video more closely.

youtube is good for learning trading and even finding good strategies; but for learning to code, use the mql4/5 online help and online documents, as well as the help files in metaeditor.

Download many indicators and eas on codebase and learn what each line does by searching for code/words on this website, and then, you will be able to modify your own, or even create your own.

 
Michael Charles Schefe #:

you're very lucky to get, even that response from a moderator -- HAHAHA

that's true, and these topics with AI code were getting deleted straight away before

 
@Conor Mcnamara #: that's true, and these topics with AI code were getting deleted straight away before
Correct! They are usually removed, but since the OP assured us that it was coded based on an "Online Video Course", I gave them the benefit of the doubt.
 

Forum on trading, automated trading systems and testing trading strategies

Deleted topic "4804 Error code for Momentum, CCI, RSI and moving average indicators"

Deleted by moderator Fernando Carreiro from category General
Reason: Please don't post the same topic multiple times. Continue on your existing topic — https://www.mql5.com/en/forum/478842
Hi! I have coded my handles correctly for the Momentum, CCI, RSI and MA indicators correctly. I have compiled with no errors or warning messages. When running my script through a strategy tester, I received an error stating a 4804 Error. Is there anyone who has worked around this and found a solution to a similar predicament?
Files:
 
Colin Kimble: Hi! I have coded my handles correctly for the Momentum, CCI, RSI and MA indicators correctly. I have compiled with no errors or warning messages. When running my script through a strategy tester, I received an error stating a 4804 Error. Is there anyone who has worked around this and found a solution to a similar predicament?

Your code is still riddled with errors and you are still calling the indicator functions as if they would return buffer values (which they don't). There are just too many errors and incorrect logic for us to offer you any specific guidance.

You need to seriously make the effort to study MQL5 properly. Read the MQL5 programming for traders - Book on MQL5.com, and study code examples in the CodeBase. Start with a small simple project and slowly build on it.

And if you are not willing to do that, then hire someone in the Freelance section to code it for you.

 
Fernando Carreiro #:

Your code is still riddled with errors and you are still calling the indicator functions as if they would return buffer values (which they don't). There are just too many errors and incorrect logic for us to offer you any specific guidance.

You need to seriously make the effort to study MQL5 properly. Read the MQL5 programming for traders - Book on MQL5.com, and study code examples in the CodeBase. Start with a small simple project and slowly build on it.

And if you are not willing to do that, then hire someone in the Freelance section to code it for you.

How can there be errors and incorrect logic if it has compiled successfully without errors or warnings?
 
Colin Kimble #: How can there be errors and incorrect logic if it has compiled successfully without errors or warnings?

Do you really think that programming is that easy? Just because it compiles, you think it is all correct?

Are you not here asking for help because it still does not work, even after it compiles?

I repeat ...

  • There are many errors.
  • Your code is very "stringy" and "all-over-the-place".
  • The logic is completely messed up.

You need to go back to start, and begin with the basics. Start with a very small and simple program.

Study the examples in the CodeBase, and read the MQL5 book already mentioned, while referencing the documentation.

 
Fernando Carreiro #:

Do you really think that programming is that easy? Just because it compiles, you think it is all correct?

Are you not here asking for help because it still does not work, even after it compiles?

I repeat ...

  • There are many errors.
  • Your code is very "stringy" and "all-over-the-place".
  • The logic is completely messed up.

You need to go back to start, and begin with the basics. Start with a very small and simple program.

Study the examples in the CodeBase, and read the MQL5 book already mentioned, while referencing the documentation.

I assume that it's probably a very small issue that can get fixed without the dramatic effects .....