An object oriented language for Empty4

Post Reply
User avatar
Steve Gill
Posts: 4
Joined: Thu Dec 08, 2011 9:39 pm

Re: An object oriented language for Empty4

Post by Steve Gill »

This looks very interesting, thanks for this Roger. I'm experienced in MQL but just starting with Ninjatrader coding, so looking forward to investigating what you've done further, might help my learning process at the very least!
roger-write
Trader
Posts: 63
Joined: Sat May 19, 2012 10:34 am

Re: An object oriented language for Empty4

Post by roger-write »

Having used oq now for a bit, one observation is that the size of your ex4 file will grow pretty rapidly. Compiling my framework at the moment produces a 140k ex4 file and I'm just getting started (to date the largest EA I've ever created was about 450K, pre-oq). I'm maybe a tenth of what it will eventually be, putting the result at over 1 meg. A tad concerned, I did a search for any limitations with Empty4 in this regard. I found a guy whose EA was 85,000 lines of code and created an ex4 file of over 5 Meg's, so I think it should be ok as I don't see things getting that big. He did mention that he ran into an upper limit with 95,000 lines of code and 4,000 globals. He got compiler errors and had to scale back.

I thought I would bring this up in case anyone is toying with the idea of using oq. If you do, your ex4 files will end up being a bit bigger than they normally would. But it shouldn't be a problem. In my estimation, the oq/Empty4 combination should allow developers to create rather large, complex systems.
User avatar
Jonathan2FI
Trader
Posts: 119
Joined: Fri Jun 15, 2012 9:26 am
Location: Birmingham, Frankfurt, Brussels

Re: An object oriented language for Empty4

Post by Jonathan2FI »

Roger,
interesting project and reminds me a little of the front end I use on EA development - I have been using EA Wizard strategy quant for about 3 months because of its easy to integrate indi s clone rules and generate documented EAs in Mql4 very fast paid about $40 for it quite good support etc and have gone live with some EAs. How do you think yours would improve on EA Wiz. Ease of use, support manuals, more standard templates, integration of indi s, trade management tools, speed of resulting EAs?
Jonathan
roger-write
Trader
Posts: 63
Joined: Sat May 19, 2012 10:34 am

Re: An object oriented language for Empty4

Post by roger-write »

I'm not familiar with EA Wiz, but I'll try and make some time this week to check it out to see if its related or how oq compares. What I was going for with oq was at least a pseudo object oriented front end, which oq seems to have accomplished. Classes, inheritance, etc. While oq is certainly valuable, the real value will come in the framework being created using it. I haven't decided how much of that I'll be sharing yet. I'm still trying to get my head around the whole open source idea, being a software engineer for so long and making a living doing it. I like the idea of working for free with a community of fellow developers, but the reality of having to make a living is very real as well. But perhaps I can at least release part of the framework when it's ready.

At any rate, I'll look into EA Wiz to see how it compares.
roger-write
Trader
Posts: 63
Joined: Sat May 19, 2012 10:34 am

Re: An object oriented language for Empty4

Post by roger-write »

I watched the video to EA Wizard and formed a couple of opinions about it. Obviously without purchasing and using it, it is by no means an in depth analysis. First off, the premise behind EA Wiz is something I've been on board with for some time now: in forex you have to try LOTS AND LOTS of ideas. You dream about an idea, wake up in the morning and need to implement it (preferably relatively quickly) to test the theory. Sometimes it works and sometimes it doesn't (or sometimes it just needs some refining). It appears that EA Wiz allows you to do just this. Test theories on a whim.

Also, the most obvious benefit is for non programmers who would like to be able to create their own EA's. Looks like it has a nice user interface and provides lots of flexibility. For me, this benefit isn't as important since I've been coding since before Microsoft was a company and nobody owned home computers. It would probably be harder for me to navigate all the dialogues than simply write the code to do it.

Also, as flexible as EA Wiz is, ultimately it is still a canned approach, meaning that you WILL come up with scenarios that it won't handle. There are some incredibly complex trade management scenarios that would be difficult or impossible to configure in a package like EA Wiz. Or consider an EA that traverses history to find S/R levels based on fractals, fibbs, psych levels, or what have you and make trading decisions based on those levels. Maybe EA Wiz can do that, or maybe not, I don't know.

But oq won't necessarily make it easier either. The purpose of oq is quite different, which is to provide a better development environment for coders. Oddly enough, the ultimate end result is the same (at least when you factor in a really excellent framework or library), which is to quickly and easily create EA's based on complex ideas. Doing this in a language, and if the library is done correctly, it will always be more flexible than a UI app like EA Wiz. More flexible, but not necessarily easier to use.

Well, I've rambled on long enough.
roger-write
Trader
Posts: 63
Joined: Sat May 19, 2012 10:34 am

Re: An object oriented language for Empty4

Post by roger-write »

Overloading in MQL? Well, sort of.....

Anyone knowledgable about OOP languages have probably heard of something called overloading. What this means is that for a given method/function, different sets of arguments can be structured to invoke different behavior. So for example:

Code: Select all

int MyMethod(string txt, double val)
{
    <do one thing>
}

int MyMethod(int ix)
{
    <do something else>
}
In a non OOP language, this would be a problem since you can't have a function with the same name. Just to clarify, calling the above in an OOP language would invoke the correct one based upon which parameters are passed. So continuing our example:

Code: Select all

    int result1 = MyMethod("SomeText", 4.5);
    int result2 = MyMethod(index);
These two calls will invoke the different functions in the previous code block and each have their own unique behavior. Obviously you would only be able to call a method so long as there is an argument content match with one the coder has defined otherwise an error occurs.

So how does this relate to oq? No, oq will not allow you to do this. At least in this incarnation of oq. If it ever becomes a full-on language it will, but not now. However, there are techniques you can use to sort of do overloading in oq and even MQL. Consider this: I have a resource class called Rsc and I can either get to resources by name or by object id. It would be cool to be able to use the same method, let's call it Rsc:GetDouble and either pass the resource name or id and have it automatically get the resource double value. You can pull this off as follows:

Code: Select all

double GetDouble(string name)
{
  int id;
  if( IsValidInteger(name) ) id = StrToInteger(name);
  else id = GetIdByName(name);
  return(GetDoubleID(id));
}

double GetDoubleID(int id)
{
  <do whatever to get double value>
}
Then when calling GetDouble you can do either of the following:

Code: Select all

double result1 = GetDouble("MyResource");
double result2 = GetDouble(RscID);
The reason this works in MQL is that when you pass an integer (or double or whatever) in MQL to a function that is expecting a string, MQL will automatically convert the number to a string. I wouldn't call this elegant by any stretch, but it does accomplish pseudo overloading at the expense of a few extra CPU ticks. In the above example, you would need to supply the IsValidInteger functions, as well as obviously GetIdByName. But hopefully you get the idea.
Frenetic
Posts: 7
Joined: Tue Sep 04, 2012 1:32 am

Re: An object oriented language for Empty4

Post by Frenetic »

Hi roger-write, first off, interesting project. I'm a bit of an amateur when it comes to programming so please indulge my queries.

1. What would you use overloading for? Wouldn't it be neater to avoid it completely?
2. Would MQL5 be sufficiently object-oriented for most purposes?
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: An object oriented language for Empty4

Post by NeoTrader »

hi roger-write,

just stumbled over this. This is an impressive project you have started here.
Since you're such an old dog... ;) Did you developed you pre-parser by yourself or did you use any tools?

I would love to dive more into your MQL-OO-Approach but have my hands full with my own little project.

I hope that we also will get a peek in your framework or some parts of it. I think this could help that more programmers grab the concepts.

I learned quite a few programming tricks by reading code from other people...and this since the Commodore 64... ;)

Especially if you start to learn a new programming language it is a good learning strategy and helps you to get fast to grips if your read sources from people who are already proficient with the language.

Thanks for your great contribution to our community,


happy trading,

Robert

-
roger-write
Trader
Posts: 63
Joined: Sat May 19, 2012 10:34 am

Re: An object oriented language for Empty4

Post by roger-write »

Frenetic wrote:Hi roger-write, first off, interesting project. I'm a bit of an amateur when it comes to programming so please indulge my queries.

1. What would you use overloading for? Wouldn't it be neater to avoid it completely?
2. Would MQL5 be sufficiently object-oriented for most purposes?
It's really a personal preference. In the OOP world, developers use this all the time. So instead of having to think up more cumbersome names like GetValueByName and GetValueByIndex, they can just name it GetValue and have the passed arguments dictate which one to use. But you can also avoid overloading completely if you feel that it sacrifices clarity. Again, it's more of a personal preference. When I code, I am always making the assumption that another programmer is going to be using what I create and so what would make the most sense.

I hope that helps.
Last edited by roger-write on Mon Feb 18, 2013 3:42 pm, edited 1 time in total.
roger-write
Trader
Posts: 63
Joined: Sat May 19, 2012 10:34 am

Re: An object oriented language for Empty4

Post by roger-write »

NeoTrader wrote:I hope that we also will get a peek in your framework or some parts of it. I think this could help that more programmers grab the concepts.

Especially if you start to learn a new programming language it is a good learning strategy and helps you to get fast to grips if your read sources from people who are already proficient with the language.-
Thanks, Neo for the input. I agree completely. I realize that the only way OQ will become more used is if there is something that will be of great benefit that requires people to download and use it.

I believe I've come up with a plan that will work well. Here it is: Once I get to some point with the JETS framework (Joinable & Extendable Trading System), I plan to offer two ways you can get it:

1) If you are using it for personal use only, you may have it for free. Source code and all.

2) If you want to use it in any kind of commercial capacity (trade for other people, create a bot for a managed fund, sell an EA or indicator, etc.), then you must negotiate a licensing agreement with me (or my company once it is formed).

I think that should pretty much satisfy everyone involved and give people the opportunity to see the power of what can be done with OOP using oq. As for when the first incarnation of JETS will be available? It's hard to say. There's still quite a bit of work to be done, but you'll hear about it here first.
Post Reply

Return to “Coders Hangout”