| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| An object oriented language for Empty4 https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1393 |
Page 3 of 8 |
| Author: | roger-write [ Tue Jan 22, 2013 3:09 pm ] |
| Post subject: | Re: An object oriented language for Empty4 |
I've updated oq on the first page with v0.95, as well as all the example files. Changes to oq.exe: - I no longer allow it to delete all the files in target. I felt this was too dangerous for newbies. Don't want someone accidentally deleting a bunch of files. - You now specify a Project name in the build file. This will be the name of the created .mq4 and .ex4 file (instead of Classes.mq4). - Changed Combine to a Y|N option - Got rid of Query since it's no longer needed (not deleting target files anymore) - Fixed a couple of things, including one more nasty thing with static inheritance. Should work ok now. Thanks to Steve for allowing me to post .oq files directly instead of having to zip them. |
|
| Author: | roger-write [ Tue Jan 22, 2013 3:33 pm ] |
| Post subject: | Re: An object oriented language for Empty4 |
Attached you will find an oq file that contains a primarily static class called Err. It allows you to use Err:Init() to direct error messages to either the standard terminal window, or to a file you name, or to both at the same time. Then you use Err:Msg to write an error message. Nothing too clever. But I want to show how you can install your own custom error handler using static inheritance. So let's say you have a large code base and whenever it encounters an error, it calls Err:Msg. But you're creating a custom EA and would like to change the behavior of what Err:Msg does. But the key is, you don't want to have to go through all the code changing all the calls to Err:Msg (which ultimately leads to a sw maintenance nightmare). Here's what you can do: Code: Select all Code: Select all So that's an example of inheritance on a static method for the purpose of overriding the existing functionality. |
|
| Author: | roger-write [ Tue Jan 22, 2013 4:07 pm ] |
| Post subject: | Re: An object oriented language for Empty4 |
The other case I could think of for static method inheritance is for extending existing behavior, rather than simply overriding it. I've already used this in my own code to great effect. Here's the example: In the framework I'm working on, I have resource values. Various modules use certain resource values. Think of them a little like the input values that Empty4 provide, but much more comprehensive with categories, etc. I wanted to be able to validate these resources when the EA first runs to make sure it has what it needs (rather than waiting until it tries to open a trade or something and finding out it doesn't have what it needs). Using standard mql you would do something like this: Code: Select all Code: Select all Code: Select all Code: Select all The net effect is that you've done no hacking whatsoever in any other module other than the module you are directly working in, and everything just magically works. Let me know if further clarification is needed. |
|
| Author: | mjws00 [ Tue Jan 22, 2013 9:20 pm ] |
| Post subject: | Re: An object oriented language for Empty4 |
Roger, This is a very cool and ambitious project. I'm certainly watching with interest. Just thought it might be nice to know there are more interested folks. I like my OOP. Haven't gone deep enough to try this variation you've created yet. But it certainly has potential. Mike |
|
| Author: | roger-write [ Tue Jan 22, 2013 11:44 pm ] |
| Post subject: | Re: An object oriented language for Empty4 |
Thanks for the encouragement. I realize change doesn't come easy, but I'm working on this project regardless and it helps to clarify my thoughts by writing out the details. |
|
| Author: | SteveHopwood [ Wed Jan 23, 2013 12:29 am ] |
| Post subject: | Re: An object oriented language for Empty4 |
Roger, you appear to be plowing something of a lonely furrow here. I have lost a couple of brushes with OOP over the years, getting lost in a morass of classes, inheritance and gawps know what else. Maybe I am too dim to take it all on board *ignores confirmatory bellow of, "Yep, fella. Got it in 99" from offstage*; maybe it was all too badly explained; maybe I just wasn't ready for it. Whatever. What I am trying to explain here is why I have not contributed here. I may try to come to grips with it one day. For now, I am simply too busy. As a hack coder who holds Proper Programmers in awe, I am vastly impressed by what you are attempting to do here. I have done the very least I can do, which is to make this thread a 'sticky' so it cannot drift off into oblivion once you have finished posting. Hey, who knows? Maybe in a couple of weeks time you might be discussing abstruse points with the Brains Trust here. I hope so. If there is anything else I can do to help, you only have to ask. |
|
| Author: | banzak [ Wed Jan 23, 2013 11:19 am ] |
| Post subject: | Re: An object oriented language for Empty4 |
Hi Roger, this sounds very interesting and i will give it a try to convert my existing ea. If you need some help with your manual, I will help you. Regards, Banzak |
|
| Author: | roger-write [ Wed Jan 23, 2013 11:50 am ] |
| Post subject: | Re: An object oriented language for Empty4 |
Thanks for the comments Steve and banzak. I personally won't have time to start on the manual for a bit, but I suspect some of what I've already posted here could be recycled into the basis of a manual. The other thing I'm thinking is that oq may not fully catch on until there is something developed in it that people want and need. Then there will be no choice but to download it and use it to Buld the project. For me OOP has been a journey that started back in the early 90's when the company I worked for brought in a guy to teach the engineers what it was all about. It sounded cool, but it took me awhile and several projects to appreciate how elegant well-designed OO code can be. But I remember at first it felt like I was trying to code while standing on my head. Instead of just blasting out miles of code from your fingertips, I had to actually think more carefully about how to structure things. And in some ways, I think that is at least part of the point. |
|
| Author: | banzak [ Wed Jan 23, 2013 12:22 pm ] |
| Post subject: | Re: An object oriented language for Empty4 |
Hi Roger, so I will start to collect all your posts here an start a manual, I will send you the draft when I'm finished. Another question: How is the performance eg. in backtests, cause with my latest ea a backtest take me with 90% tick-data about 4 hours for a year. Regards, Banzak |
|
| Author: | roger-write [ Wed Jan 23, 2013 12:34 pm ] |
| Post subject: | Re: An object oriented language for Empty4 |
One of the goals I had going into this project was to be able to dynamically add or extend functionality to an existing library (I even named the framework I'm creating using oq: Joinable & Extenable Trading System - JETS - and, no it has nothing to do with the sports team There was one piece missing, and I believe I worked it out last night. Normally in OOP you create a subclass object by calling the subclass constructor. For example, in the example Data.oq module posted at the beginning of this thread, to create a Double object, you call Double:New, but then you can refer to the object using the Data interface. And oq does this just fine. Notice that Data does not have a constructor. If you tried to create one, you'd scratch your head and say what am I creating? It's like asking God to create a felidae without specifying what kind of cat? But there is a case to be made for being able to call the superclass constructor and have it morph into what you want. In the normal case listed above, you have to add some code somewhere that specifically calls the subclass constructor. But what if you didn't have to, assuming the signatures (or argument list) are identical? What if you could call a superclass constructor with only the kind of thing you want and have it morph and return the kind of object you want? Consider the following: Let's say you have a high level class called Trader. The Trader gives you some general methods like Refresh, but a subclass of Trader can be designed to manage a series of trades in any way you want it to. Maybe you want a Trader that opens a full size trade and then scales out as you come into profit, or whatever ( ScaleOutTrader). Think of an EA where as one of the input parameters you actually give the name of the kind of Trader you want it to use. The EA code looks up the name and finds a kind value which gets passed to the superclass constructor, Trader:New(kind, heterogeneous_list) and it returns an object ID to a ScaleOutTrader. The EA code deals with the object as a Trader and doesn't care what kind it really is. Basic OOP stuff. But the implications are, I can then at some later point develop a new kind of Trader, lets call him ScaleInTrader, install it into my project and never touch another piece of code in the project and it will just work. Soon I'll post the way you create a morphable superclass constructor with oq, along with yet another update to make this happen. |
|
| All times are UTC | Page 3 of 8 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|