Trade Class or Trade functions, what is the difference, which one is better

 

Hi Expert,


MQL5 reference has a standard library and contain a trade class, one of them is ctrade.


However, Under same MQL5 reference, there are trade functions also.


I found both can perform trade operation, but when programming, what is the difference, and which one is better?


Can share your expert idea?


Thanks.

 
Dicky Lam: Hi Expert, MQL5 reference has a standard library and contain a trade class, one of them is ctrade. However, Under same MQL5 reference, there are trade functions also. I found both can perform trade operation, but when programming, what is the difference, and which one is better? Can share your expert idea?

Both methods have their advantages and disadvantages. It depends on your coding style. Do you prefer to program in a procedural or functional way of logic, or do you prefer a more object oriented way?

Comparison of programming paradigms

Paradigm Description Main traits Related paradigm(s) Critique Examples
Procedural Derived from structured programming, based on the concept of modular programming or the procedure call Local variables, sequence, selection, iteration, and modularization Structured, imperative
C, C++, Lisp, PHP, Python
Functional Treats computation as the evaluation of mathematical functions avoiding state and mutable data Lambda calculus, compositionality, formula, recursion, referential transparency, no side effects Declarative
C++, [2]C#, [3] [circular reference]Clojure, CoffeeScript, [4]Elixir, Erlang, F#, Haskell, Java (since version 8), Kotlin, Lisp, Python, R, [5]Ruby, Scala, SequenceL, Standard ML, JavaScript, Elm
Object-oriented Treats datafields as objects manipulated through predefined methods only Objects, methods, message passing, information hiding, data abstraction, encapsulation, polymorphism, inheritance, serialization-marshalling Procedural See its Criticism selection, and elsewhere [6] [7] [8] Common Lisp, C++, C#, Eiffel, Java, Kotlin, PHP, Python, Ruby, Scala, JavaScript [9] [10]
 

Hi Fernando Carreiro,


Thanks your information.


I prefer object oriented method, so trade class is it, right ? 

 
Dicky Lam #: Hi Fernando Carreiro, Thanks your information. I prefer object oriented method, so trade class is it, right ? 

That is up to you to decide.

I personally prefer procedural/functional as I have more control to make it more efficient and consume less resources.

On the few occasions I do use OOP, I write my own classes. I don't trust the Standard Library, due to its many bugs.