An object oriented language for Empty4

Post Reply
Frenetic
Posts: 7
Joined: Tue Sep 04, 2012 1:32 am

Re: An object oriented language for Empty4

Post by Frenetic »

roger-write wrote:
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.
Thanks for the elaboration.

Haven't really found a compelling need for OO yet but I gather it somewhat ties in nicely with collaborative work.
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've added an update to oq (version 0.97) on the first post of this thread. Here's what I can remember about the various changes:

- Improved a bunch of messages when errors occur to make them a bit more intuitive.
- Fixed a bug for when Make (in build file) was set to 'N'
- Added a built in function called ObjectCounts() you can call at any time and it will print to the terminal window the current count of all root objects, along with the size of the root objects array in parenthesis. Used for debugging in case you want to see object counts.
- There was a fundamental problem with referring to methods in a subclass where the method had been overridden. Oq needed to go to the highest patriarch with that method name instead of the lowest. That way switching can occur properly and it lands in the correct method given the class type. A bit confusing, but it took me several hours to figure out why things weren't behaving as expected. It's all good now.

I think that's all I can think of for the moment. However, I do want to mention that I came across a nasty Empty4 compiler or executer bug. I was able to get around it, but that's just plain annoying. Instead of this:

Code: Select all

Global[index] = Function();
I ended up having to do this:

Code: Select all

int val = Function();
Global[index] = val;
The first case above was not working and the second case was. Very odd. We've all done this a hundred times, but in this one case it failed for some weird reason. If anyone has any wisdom on this, I'm all ears.
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 thought I'd post an EA created from the JETS framework I'm developing. Not ready to release all the source code yet, as I have a long way to go. But this teaser EA is still mildly useful in it's own right, and I've included the root source file to show what it will look like creating an EA using JETS in the future. In case you missed it JETS stands for Joinable & Extendable Trading System, and is coded in ObjectQuotes.

To install:

- Unzip the package
- Obviously put JETS-TeaserEA.ex4 into the experts directory
- Put JETSLib.dll into the experts\libraries directory
- Create a directory under experts\files called JETS (and do the same under tester\files if you want to test it with the strategy tester
- Put JETS.rsc and JETS-TeaserEA.rsc under the newly created JETS directory(s)
- Feel free to look at the root source JETS-Teaser.oq if you're a coder

Description:

This is a very simple EA that, when applied, will immediately enter either a buy trade or a sell trade. The "mildly useful" aspect of this EA is the trade management. But the real purpose is to begin to show how JETS will, at some point in the hopefully not too distant future, be configured to do pretty much whatever you want it to.

JETS is resource driven via a dynamic set of resources directly tied to oq template classes. This is the Joinable/Extendible aspect of JETS. Join the pieces you want. If you don't like what it has, extend it for your own purposes. You can look at the .rsc files in notepad to get a glimpse of it. It may not make much sense at the moment, but eventually it will all get documented.

Inputs:

Side - you have to specify 1 or -1 for buy/sell
Resources - the name of the resource file
Trader - the name of the trader object to use
Lots - trade size
TakeProfit - number of pips for TP
Stoploss - number of pips for SL
TrailLock - Pips into the money when trailing stop kicks in (using a trailing trader)
Magic - just leave it -550 for the moment
VisualSlow - if you want to slow things down in tester visual mode, increase number

How to use:

By default it's set to Trader.Simple. You can currently select one of four traders as follows:

Trader.Simple

This is a brain dead trader that puts the TP/SL values. Nothing too exciting.

Trader.Movable

This does the same thing as simple, but allows you to double-click the TP or SL line and move it dynamically on the chart, causing the underlying TP/SL to move.

Trader.Trailer

Once TrailLock is reached, it will set SL to BE plus one pip. Then trail the trade by TrailLock-1 pips. Before it locks the trailing stop, it uses Stoploss as the initial stoploss.

Trader.MovTrail

Same as Trader.Trailer, but allows you to double-click and grab the SL line at any time to move it. Once you move it, it knows you have control and will no longer automatically trail. If you have moved it and want the auto trailer to kick in again, just delete the line and it will reappear.

Enjoy!
JETS-Teaser.zip
You do not have the required permissions to view the files attached to this post.
roger-write
Trader
Posts: 63
Joined: Sat May 19, 2012 10:34 am

Re: An object oriented language for Empty4

Post by roger-write »

BTW, when using the movable lines, you may notice they don't always perfectly line up. The reason is that it won't actually modify the underlying TP/SL unless it is more than one pip tolerance to avoid excessive OrderModify calls.
User avatar
mjws00
Trader
Posts: 609
Joined: Fri Jan 04, 2013 10:17 pm
Location: Victoria

Re: An object oriented language for Empty4

Post by mjws00 »

Cool Cool. Will take a look.
Reading the dark heart.
roger-write
Trader
Posts: 63
Joined: Sat May 19, 2012 10:34 am

Re: An object oriented language for Empty4

Post by roger-write »

The next version of oq will be a major refactoring. I'm not completely satisfied yet with what oq v0.97 is. It's on the right track, but needs to be more accessible, more intuitive, easier to use, and provide a great deal more benefit than using standard mql. I've done some thinking this weekend and decided to make the object oriented aspect merely one of the benefits of oq. So if anyone is actually following this thread or has any interest in oq at all, I'll be in the process of rebooting the project over the next few weeks.

A side note about MT5. From all I can see, it looks like Metaquotes failed big time. Yes, it has OOP, but it appears to be slower, and removing the ability to hedge is clearly a death sentence. Since Empty4 appears here to stay and since so many have so much invested in it, regardless of the problems, I believe it's still worth putting time into this project.

If time permits, I'll also try to work out at least a tutorial for the rebooted oq, and provide a couple of actual profitable EA's as examples. I have a couple of good ones I can port to oq for example purposes, etc. It would be nice to put together a decent indicator example as well. As far as how long this will take is anyone's guess.

If there is any interest in collaboration on any of this feel free to chime in.

Interest or not, I know coders are busy on their own projects. But I honestly believe this could ultimately make sharing of modules much easier, otherwise I wouldn't be so vested in this project. I wish you all success in whatever you are working on.

Peace out!
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
roger-write wrote:The next version of oq will be a major refactoring. I'm not completely satisfied yet with what oq v0.97 is. It's on the right track, but needs to be more accessible, more intuitive, easier to use, and provide a great deal more benefit than using standard mql. I've done some thinking this weekend and decided to make the object oriented aspect merely one of the benefits of oq. So if anyone is actually following this thread or has any interest in oq at all, I'll be in the process of rebooting the project over the next few weeks.
It's great to hear that you are trying to get new life in our hated MQL Language and I'm following your approach with much interest.
I'm eager to see what you will come up with in the refactored version.
Keep up the good work

I'm still interested to know what tools you use for the parsing and mql-generation.
Did you developed everything yourself or do you have some tools?
roger-write wrote:A side note about MT5. From all I can see, it looks like Metaquotes failed big time. Yes, it has OOP, but it appears to be slower, and removing the ability to hedge is clearly a death sentence. Since Empty4 appears here to stay and since so many have so much invested in it, regardless of the problems, I believe it's still worth putting time into this project.
I also think that Empty4 is here to stay because there is so much invested in it and can not transfered to CrapT5.
Thats why I also try with my project to enhance its capabilities as good as possible.
However, for the long run I hope to develop the tools needed to have a migration path to better solutions since Empty4 has some major limits that are not so easy to overcome.
roger-write wrote:If time permits, I'll also try to work out at least a tutorial for the rebooted oq, and provide a couple of actual profitable EA's as examples. I have a couple of good ones I can port to oq for example purposes, etc. It would be nice to put together a decent indicator example as well. As far as how long this will take is anyone's guess.
That would be great, especially if you could also provide sourcecode how to actually use OQ.

Have you ever thought about a solution to generate OQ from MQL? Was only just an Idea that past my mind right now. This way developer could maybe compare both codes and see how it is expressed in OQ. Just a thought... ;)
roger-write wrote:If there is any interest in collaboration on any of this feel free to chime in.
I would love to jump in with you but as you know I have my own little ambitious project on the plate.
However I hope at some point that we can join forces since I think you're a great developer.
roger-write wrote:Interest or not, I know coders are busy on their own projects. But I honestly believe this could ultimately make sharing of modules much easier, otherwise I wouldn't be so vested in this project. I wish you all success in whatever you are working on.
I also think that it could ease a couple of things in Empty4 development...maybe at some time we could develop it to some sort of intermediary language that we can use to build generators on top of it for other platforms besides MQL (zorro, flashtester, AmiBroker, NinjaTrader and so on) just a thought... would be a great asset in our toolset.

I hope to see you at some point in our Portal... ;)


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 »

NeoTrader wrote: I'm still interested to know what tools you use for the parsing and mql-generation.
Did you developed everything yourself or do you have some tools?
Sorry I forgot to address this. I coded oq.exe from scratch using C#. I'm about to save a copy of my v0.97 project and then gut and refactor it. For example, one thing I plan to do is allow a coder to do something like "oq new expert <name>" and have it create an oq project with build file and an empty shell to fill out. Or "oq new indicator <name>", etc.
NeoTrader wrote: Thats why I also try with my project to enhance its capabilities as good as possible.
However, for the long run I hope to develop the tools needed to have a migration path to better solutions since Empty4 has some major limits that are not so easy to overcome.
Exactly. Theoretically, oq code could eventually output to other platforms besides Empty4.
NeoTrader wrote:That would be great, especially if you could also provide sourcecode how to actually use OQ.
Absolutely. I plan to provide all the oq source for the EA's once they've been ported. One is a grid trader which has been used before on a managed fund, and another is based on VSA principles and has been successful since launching on a demo account from last summer. It doesn't trade much and only works on EURUSD 30M, but it is, in fact successful. Maybe when I post it and someone latches onto it, they can find a way to make it work successfully on other pairs and timeframes.
NeoTrader wrote:Have you ever thought about a solution to generate OQ from MQL? Was only just an Idea that past my mind right now. This way developer could maybe compare both codes and see how it is expressed in OQ. Just a thought... ;)
Attempting to write oq in mql would most certainly challenge my coding abilities. :D It's only going to get more complex and I kind of need the full resources of something like C# to pull it off. Once it's where I want it, I have no problem posting the C# project for others to look at.

Thanks for the encouragement, and good luck with your project as well. I suspect our projects may intersect at some point in the future.
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,
roger-write wrote:Attempting to write oq in mql would most certainly challenge my coding abilities. :D
Not only yours... ;)
I maybe didn't expressed myself well. I'm not a sadist...it would never cross my mind to create something like OQ in MQL.
I meant to parse MQL and create/convert it to OQ. This way people who know MQL would have a possibility to compare both sources to learn how OQ expresses particular MQL.

Another benefit if such functionality would be available is that we could convert the large MQL source code base faster to OQ and therefore have the ability to refactor this codebase into a more OO based approach.
I know that this is a lot of work..but maybe for the future.. ;)
roger-write wrote:It's only going to get more complex and I kind of need the full resources of something like C# to pull it off. Once it's where I want it, I have no problem posting the C# project for others to look at.
I would be very interested in getting a peek in your code once it is done.
So you wrote a complete OQ parser and the MQL generator yourself. Thats quite impressive.

When you refactor the whole thing it would be great if you could try to modularize it in a way that we could have the ability to plug in other destination platforms at a later time.
Since I don't know your source code I really don't know if this is possible but maybe you could keep the thought in the back of your mind.
roger-write wrote:Thanks for the encouragement, and good luck with your project as well. I suspect our projects may intersect at some point in the future.
Thanks again for your hard and creative work.

I would love to find a way where our two project could intersect in the future.


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 »

NeoTrader wrote:So you wrote a complete OQ parser and the MQL generator yourself. Thats quite impressive.
It may not be quite as impressive as you might think. Oq parses primarily the class structure elements but mostly leaves the contents of the body of the methods/functions intact. In other words, I don't parse out every name, token and expression, etc in the flow of code. Oq will take the body of a class method/function and copy it straight into mql. The only exception to this is that it will scan for the @ and : characters and do some replacements based on the surrounding names. But for the most part, once you're inside a class method, the code looks exactly like mql with the mentioned exceptions.

As for converting from mql to oq, you can actually take your existing mql code and run it thru oq without any issue, because anything outside the class {} construct will just get passed straight thru anyway. A good way for coders to start getting accustomed to oq might be to simply take an existing ea or indicator's code and set it up to build thru oq. Then they can start experimenting with a class here or there as needed. But hopefully the reboot, documentation, and examples will go a long way in helping people get accustomed to it. But the existing base of code should co-exist just fine inside oq.

Hopefully this makes sense.

One last thing. The rebooted oq will have types of classes called templates. There will be a standard template definition for, say, a trader mechanism or a signal, or an ea manager, etc. When the time comes, I really would like input from coders on defining the various templates. Once these are defined, then lets say a coder wants to create a new signal module for NB's 10.4 system, then all they do is follow the spec for the signal template (what methods are required, etc) and then anyone using oq could simply plug in the new signal and their EAs or indicators become NB 10.4 aware, so to speak.
Post Reply

Return to “Coders Hangout”