Download MetaTrader 5

Please check my code, I am starting to learn MQL - page 2

To add comments, please log in or register
tatyawinchu
101
tatyawinchu  
deVries:

Now the other problem, you can have with this code

Might be it is not always happening,

but if closing happens and one trade fails to close you keep that trade


yes.. and its FUN because I can actually now read an understand at least something about what the code does =D .. hehe its surely a brick wall breaking experience .. functions are sweet =D.. I mean once I master functions, I can have my own set of custom functions.. written once, and can be called again and again for various repetitive jobs .. kickass B-)
Daniel Petrovai
440
Daniel Petrovai  
tatyawinchu:


FANTASTIC .. and pretty nicely explained .. Functions are fantastic .. they open up such a beautiful world .. =D .. Plus my friend just gave me a book called "Spirit of C" .. LOVING it.. do you know of it?

Yes, functions are a great tool, not hard to understand and reusable. Once you have one that works just copy and paste and you new EA is ready in no time. At least for testing new ideas.
tatyawinchu
101
tatyawinchu  
thrdel:

Yes, functions are a great tool, not hard to understand and reusable. Once you have one that works just copy and paste and you new EA is ready in no time. At least for testing new ideas.


Now addicted to C ! Reading Spirit of C by Moolish Cooper. Then C++ =D .. This is cool new hobby I found ..Learning something new is wonderful especially when markets are cold.. B-)

Daniel Petrovai
440
Daniel Petrovai  
tatyawinchu:


Now addicted to C ! Reading Spirit of C by Moolish Cooper. Then C++ =D .. This is cool new hobby I found ..Learning something new is wonderful especially when markets are cold.. B-)


Learning C or C++ is good but when you get to Java, then you'll see the mother of MQL.

tatyawinchu
101
tatyawinchu  
thrdel:


Learning C or C++ is good but when you get to Java, then you'll see the mother of MQL.


Haha ! your reply has kind of initiated a heated debate between two techy friends of mine !

Friend 1: Learning C is the fundamental building block .. learn C as 3rd gen language and you will be able to learn any other language 3rd or 4th very easily later on.

Friend 2: No No No, the other way round .. learn Java or VB first.. drop VB as java is more prefered .. But, if you learn java first, you are AS good a coder and you dont HAVE to learn C or C++ ..Plus the very claim that you have to learn C to be a good coder is wrong..

Me: I will ask thrdel ! xD

So whats your opinion? =)

Daniel Petrovai
440
Daniel Petrovai  
tatyawinchu:


Haha ! your reply has kind of initiated a heated debate between two techy friends of mine !

Friend 1: Learning C is the fundamental building block .. learn C as 3rd gen language and you will be able to learn any other language 3rd or 4th very easily later on.

Friend 2: No No No, the other way round .. learn Java or VB first.. drop VB as java is more prefered .. But, if you learn java first, you are AS good a coder and you dont HAVE to learn C or C++ ..Plus the very claim that you have to learn C to be a good coder is wrong..

Me: I will ask thrdel ! xD

So whats your opinion? =)


My opinion is as valid as anyone else's . I believe that you don't need to learn to fly a jet fighter to ride a bike. If you can learn Java or MQL or C or C++, that means you have the ability to learn.

We use the documentation in MQL and so do the Java programmers and the C++ or whatever. They don't just memorize everything there is to know about that particular system.

Java is everywhere this days, from your mobile phone, car, computer, you name it.

And as I said before, I you need to write MQL, learn MQL. It is based on Java. But it's MQL.

No C or C++ programmer can do what one can do in assembly programming. Is that better ? Yes, if you're interested in reverse engineering. No, if you want to write EA's.

So the question isn't that simple but it is simple at the same time.

Hope it makes sense.

Noddy
9
Noddy  
thrdel:


My opinion is as valid as anyone else's . I believe that you don't need to learn to fly a jet fighter to ride a bike. If you can learn Java or MQL or C or C++, that means you have the ability to learn.

We use the documentation in MQL and so do the Java programmers and the C++ or whatever. They don't just memorize everything there is to know about that particular system.

Java is everywhere this days, from your mobile phone, car, computer, you name it.

And as I said before, I you need to write MQL, learn MQL. It is based on Java. But it's MQL.

No C or C++ programmer can do what one can do in assembly programming. Is that better ? Yes, if you're interested in reverse engineering. No, if you want to write EA's.

So the question isn't that simple but it is simple at the same time.

Hope it makes sense.

Hi everyone,

Sorry to be precise but MQL4 is based on C and MQL5 is based on C++. Java is based on C, C++, and some other high level languages and I think they all have copied bits from each other over the years. I really doubt it matters with MetaTrader and MQL but in terms of pure execution speed Java is often actually slower than C but some things like memory allocation and management is easier in Java as the code to do it was refined for Java but C is often more powerful and versatile. The speed reason is why commercial OSs have only been produced with C/C++ and only experimented with in Java.

In many high level languages you can embed assembly language into sections that need to work much faster than with traditional high level code. I'm not sure how relevant it is or even if it as a good idea to use these days but I have considered learning assembly language if I ever need to write an EA that needs to run as fast as possible.

I don't think MQL directly supports assembly language but it may be possible to write it as part of an DLL and include functions within the EA to make use of it. It would be great if someone could clarify if assembly language is possible in MQL somehow should it ever be needed. If I ever get the time I might even try something basic and post it to the codebase for everyone.

Anyways, sorry I got a bit off topic. As for the OP question it would be better to learn C/C++ first as it is more like MQL4/5 then learn the few differences to code in Java but as thrdel stated above, most of the languages are very similar so learning one or the other first isn't too much of a big deal but learning C/C++ first will be more adaptable to writing MQL faster as it is the almost the same language.

Cheers,

Noddy
Alain Verleyen
Moderator
32427
Alain Verleyen  
tatyawinchu:


Haha ! your reply has kind of initiated a heated debate between two techy friends of mine !

Friend 1: Learning C is the fundamental building block .. learn C as 3rd gen language and you will be able to learn any other language 3rd or 4th very easily later on.

Friend 2: No No No, the other way round .. learn Java or VB first.. drop VB as java is more prefered .. But, if you learn java first, you are AS good a coder and you dont HAVE to learn C or C++ ..Plus the very claim that you have to learn C to be a good coder is wrong..

Me: I will ask thrdel ! xD

So whats your opinion? =)

You don't have to learn any specific language to be a good coder, you can be a good coder (or a bad one) in any language. What you need to be a good coder is, as thrdel wrote, firstly the capacity to learn, and secondly logical thinking. With that you can learn any language and be good at it.

Debate around C, C++, Java or D, X, Y, Z languages are endless and waste of time.

tatyawinchu
101
tatyawinchu  
THIS FORUM IS A GEM =D
12
To add comments, please log in or register