how to put strings (AccountBalance && AccountEquity) in a row?

 

I found the multiple line section in documentation, but didn't understand how to separate functions.

Comment(StringFormat("Equity is %.2f", AccountEquity()));
Files:
 

This code answers your question and is valid for both MQL5 and MQL4+.

Comment( StringFormat( "Equity is %.2f and Balance is %.2f", AccountInfoDouble( ACCOUNT_EQUITY ), AccountInfoDouble( ACCOUNT_BALANCE ) ) );

Please note that "AccountEquity()" is not a valid MQL5 function. That is from the old MQL4 code (please see MQL4 Reference). If your questions are about MQL4, then you should post in the MT4/MQL4 section at the very end of the forum.

 
Fernando Carreiro #:

This code answers your question and is valid for both MQL5 and MQL4+.

Please note that "AccountEquity()" is not a valid MQL5 function. That is from the old MQL4 code (please see MQL4 Reference). If your questions are about MQL4, then you should post in the MT4/MQL4 section at the very end of the forum.

Hmm.. This is one of my main problems and that's why I got the error... Finish.... What the difference between AccountEquity() and AccountInfoDouble ( ACCOUNT_EQUITY)?



P.S: Don't tell about MQL4 reference please, there is rocket science, not understandable for 17 year old kid who started programming 1 week ago. I'm comfortable to ask you here.

I made this decision based on the fact that for a week now I have been looking for a sensible explanation about event handling functions, for example OnDeinit, and found it. And what again is my indifference to what I learned, how simply everything is explained NOT ON MQL4 DOCUMENTATION WEBSITE, what a 5 year old child will understand. I need this and nothing else. And this is the key to victory. Simplicity! Programming is easy. You must understand this, because you do it automatically, it is easy for you, and even more so a posteriori programming is easy.

 
IgorFX Trading #: Hmm.. This is one of my main problems and that's why I got the error... Finish.... What the difference between AccountEquity() and AccountInfoDouble ( ACCOUNT_EQUITY)?

Are you using MetaTrader v4 or you using MetaTrader v5?

If you are using MetaTrader / MQL v5, then you can only use "AccountInfoDouble ( ACCOUNT_EQUITY )" .

If you are using MetaTrader / MQL v4, then you can use both, but "AccountEquity()" is from the old MQL4 before MQL5 came out, and "AccountInfoDouble ( ACCOUNT_EQUITY )" is the more modern compatible to MQL5.

And remember, you are not a 5 year old. You are almost an adult, and as an young adult you have a responsibility to improve your knowledge by doing the research needed. That means plenty of reading, cross-referencing and much more (be it books, videos or online references). It will take many months and even years. You will not be able to learn what is necessary in just a few days or weeks. Prepare for a very long journey of learning MQL.

The same applies to any other programming language. It takes time and effort!

EDIT: And by the way, programming is easy for me, because of doing it for decades, not because of talent or "gift". Everyone that has a "gift", worked really hard and long to be able to be good at it. It did not just happen like "magic".

 
IgorFX Trading #:

Hmm.. This is one of my main problems and that's why I got the error... Finish.... What the difference between AccountEquity() and AccountInfoDouble ( ACCOUNT_EQUITY)?



P.S: Don't tell about MQL4 reference please, there is rocket science, not understandable for 17 year old kid who started programming 1 week ago. I'm comfortable to ask you here.

I made this decision based on the fact that for a week now I have been looking for a sensible explanation about event handling functions, for example OnDeinit, and found it. And what again is my indifference to what I learned, how simply everything is explained NOT ON MQL4 DOCUMENTATION WEBSITE, what a 5 year old child will understand. I need this and nothing else. And this is the key to victory. Simplicity! Programming is easy. You must understand this, because you do it automatically, it is easy for you, and even more so a posteriori programming is easy.

In addition to Fernando's post.

When programming in MQL, you get 3 types of APIs, MQL4, MQL4+ and MQL5.

Also the compilers differ slightly, but not to much. So you could consider them being equivalent.

But the available API differs. Focus on one of them. Best is to use only MQL5.

EDIT:

Something in general about MQL and programming.

MQL is an algorithmic environment. That means it has an initialization, a repetitive execution and a deinitialization.

You set up the execution environment in Init Phase, you get executed for every new dataset update, and you need to clean up when your program exits.

These are the basics about the framework you are working in.

Events and their handlers give you the opportunity to act on changes in the environment. Depending on what you are doing, accordingly you can use the execution thread you get notified by. Like OnCalculate, OnTick, OnTimer and so on...
 
Fernando Carreiro #:

Are you using MetaTrader v4 or you using MetaTrader v5?

If you are using MetaTrader / MQL v5, then you can only use "AccountInfoDouble ( ACCOUNT_EQUITY )" .

If you are using MetaTrader / MQL v4, then you can use both, but "AccountEquity()" is from the old MQL4 before MQL5 came out, and "AccountInfoDouble ( ACCOUNT_EQUITY )" is the more modern compatible to MQL5.

And remember, you are not a 5 year old. You are almost an adult, and as an young adult you have a responsibility to improve your knowledge by doing the research needed. That means plenty of reading, cross-referencing and much more (be it books, videos or online references). It will take many months and even years. You will not be able to learn what is necessary in just a few days or weeks. Prepare for a very long journey of learning MQL.

The same applies to any other programming language. It takes time and effort!

Alright. 

I used AccountEquity() in MQL4. 

Is there a page in the documentation where I will no longer get errors because I used a function from a previous version that doesn't work in the current one? 

Or I didn't understand you? I typed this function in MQL4, why didn't it work? Are you talking about the number after the word MQL or build?

 
 
IgorFX Trading #: Alright. I used AccountEquity() in MQL4. Is there a page in the documentation where I will no longer get errors because I used a function from a previous version that doesn't work in the current one? Or I didn't understand you? I typed this function in MQL4, why didn't it work?

If you are are starting out with MQL, then start with MetaTrader 5 and MQL5. MetaTrader 4 is no longer developed.

Goto to menu in MetaTrader (not MetaEditor) and select File -> About and see if you are using MetaTrader 4 or 5.

 
IgorFX Trading #: Alright. I used AccountEquity() in MQL4. Is there a page in the documentation where I will no longer get errors because I used a function from a previous version that doesn't work in the current one? Or I didn't understand you? I typed this function in MQL4, why didn't it work? Are you talking about the number after the word MQL or build?

By the way, if you use "AccountInfoDouble( ACCOUNT_EQUITY )" then it will work on both and you will not have to worry if it is MQL4 or MQL5.

So, which do you think will be the more reasonable approach — using the old function or using the new one?

 
Fernando Carreiro #:

By the way, if you use "AccountInfoDouble( ACCOUNT_EQUITY )" then it will work on both and you will not have to worry if it is MQL4 or MQL5.

So, which do you think will be the more reasonable approach — using the old function or using the new one?

MQL4 is enough for me. If I have a SIMPLE manual strategy that is profitable, then I don't need a new version to automate it, right?

 
IgorFX Trading #: MQL4 is enough for me. If I have a simple manual strategy that is profitable, then I don't need a new version to automate it.

That does not seem like a very reasonable thing to say, but if that is you decision, then you should no longer be learning from MQL5 documentation. You will have to rely on the older "MQL4 Documentation", even if you say that it looks like "rocket science". If you continue to reference the MQL5 documentation, while coding in MQL4, then you will only get more frustrated and confused.

Also, in future you should post in the MQL4 section, or else you will receive MQL5 answers which will most probably not work for you.

 
Fernando Carreiro #:

That does not seem like a very reasonable thing to say, but if that is you decision, then you should no longer be learning from MQL5 documentation. You will have to rely on the older "MQL4 Documentation", even if you say that it looks like "rocket science". If you continue to reference the MQL5 documentation, while coding in MQL4, then you will only get more frustrated and confused.

Also, in future you should post in the MQL4 section, or else you will receive MQL5 answers which will most probably not work for you.

Ok