Cubesteak Central

Archive for October, 2006

Moving Average of Volume Bonanza

October 31, 2006 5:11 pm

Ever want to have a MA of volume?

Some indicators out there would provide such a thing, but didn’t go as far as I would have liked.  So, I put hacked up someone else’s MA of Volume indicator and added a JMA option, as well as a dynamically changing level that is based upon a configurable number of days average.

Ever want to quickly see if the MA of volume is high or low based on the last 120 days?  30 days?  Now you can!

Here’s a snapshot:

mavolume.gif

Get this indicator:

MetaQuotes 4 Language File MAVolumeWithJMA.mq4
MAVolumeWithJMA.zip

3 Fold Trading Hours in a Separate Window

October 30, 2006 11:27 pm

In a previous post, I made a little time filter indicator that simply was a visual reminder if you should be trading or not based upon three configurable times. It simply used a comment in the chart window to convey the information.

In that post, I made the offer to whip up a version that had its own indicator window, if anyone thought it would be useful. Someone (Barry) did, so now we have three flavors of 3 Fold Trading Hours.

Original: Visual reminder via a chart comment
New: Visual reminder via a new indicator window (available below)
Also: Time filter for an Expert Adviser to actually stop trading from happening

This new indicator also displays a bit more information as well, like listing out the filter times, and if they are used or not. The time filter logic is taken from the EA version, so that you can now filter by hours and minutes, not just hours, as with the original.

Here’s a snapshot:

3fthours.gif

Get this indicator:

MetaQuotes 4 Language File 3FoldTradingHoursSeparateWindow.mq4
3FoldTradingHoursSeparateWindow.zip

Adding a Magic Number to an EA

October 27, 2006 12:04 am

Someone asked me if there was a manual on how to add a Magic Number to an EA. Since I haven’t seen one, I put together the following basic steps
and thought that others may find it useful too. These steps can also be used to verify that an EA properly uses a Magic Number, as some don’t!

First off, to the completely uninitiated, a Magic Number is simply an arbitrary number that can be added to an EA that is used to uniquely identify trades that are made from that EA with an eye towards differentiating them from trades made by any other EA. Without a Magic Number, a EA that closes all orders will not only close orders that it has made, but it will also close any orders made by a different EA, and it will even close orders that were made manually, as it has no way of telling which orders came from which EA.

This obviously is not an optimal situation. The Magic Number lets you differentiate these orders programatically so that you can run multiple EA’s on multiple charts from within the same MT4 instance and still be able to trade manually as well.

Anyway, now on to the steps:

1) On a global level in the EA add:

int MagicNumber = 233423; // where 233423 is any old number that is unique from any of your other running EA’s

The easiest way to describe declaring on the “global level” of the EA is a variable that is declared outside of the Start, Init and Deinit functions. The easiest way to ensure that you are on the global level of the EA is to put the MagicNumber declaration immediately after the top comments and any #property, #include or #import statements and BEFORE the Init, Deinit and Start functions.

2) Next, make sure that the OrderSend function uses this magic number. OrderSend uses the following form:

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

So, you want to make sure that it is called with the MagicNumber in it, e.g:

OrderSend(Symbol(),OP_BUY,1.0,Ask,2,10,20,”My Buy”,MagicNumber,0,Lime)

3) Then, search the EA for each instance of OrderClose, OrderModify or OrderDelete. Usually these are sandwiched by at least one IF statement. Add to that IF statement the following condition: (OrderMagicNumber() == MagicNumber)

So, something like this:

if (OrderSymbol == Symbol())
{
OrderClose(blah blah…);
}

Becomes:

if (OrderSymbol == Symbol() &&
OrderMagicNumber() == MagicNumber)
{
OrderClose(blah blah blah);
}

Voila! Your EA now uses a magic number and should be able to trade with other EAs.

Please note that any money management that an EA uses, like lot optimization based on available margin or equity, etc. will also “interfere” with each other. This is either desirable or undesirable based upon how you want to trade with the specific EA’s.

Hope that helps!

The FINAL word on EX4 decompilation…

October 20, 2006 6:44 pm

OK, the FINAL (I hope) word on decompiling EX4 files in the U.S.

If you want to refute this, please feel free (I would welcome the re-education), but don’t bother to unless you provide a URL or quote that explains a specific statute or law.

OK, here goes:

A copyright doesn’t forbid decompiling. That’s why most software companies have a EULA (end user lic. agreement) that specifically cover things like reverse engineering, decompilation, etc as well as exactly HOW you can use the software.

This is a simple issue – if you decompile something, you aren’t breaking the law (unless you signed a EULA, in which case you are technically in breach of license and can be sued). IF you choose to publish it, sell it, or do anything else with it that falls outside of “fair use” laws, then you are in breach of copyright. This isn’t so different than the whole thing that is going on with music… Saying you can’t decompile a .ex4 file is like saying you can’t rip a song from a CD to an MP3. That’s not illegal (yet).

In fact, I personally believe that it would be difficult to enforce a copyright for most EA’s. Why? Several reasons actually.

To quote wikipedia:

“Copyright law covers only the particular form or manner in which ideas or information have been manifested, the “form of material expression”. It is not designed or intended to cover the actual idea, concepts, facts, styles, or techniques which may be embodied in or represented by the copyright work.”

Most styles of trading have been done and are available in one form or another on many forums, so the “system” can’t be copyrighted. MQL4 is a small enough language where just about EVERY way of doing anything with it is also in the public domain at this point, so most likely the “code” itself can’t be copyrighted. That leaves the exact copying of the code in its entirety. WHICH, frankly goes on and is encouraged left and right in most forums and is even done in this group. Everybody puts the “copyright” statement in their code, yet then we post it to groups such as this or to online forums, freely encouraging people to copy it again and breach the copyright we just claimed. How can one breach be distinguished from the “normal” breaches that are encouraged every day? While ignorance of the law is no excuse, there is certainly plenty of precedence to say that the “copyright” statement in an EA isn’t really a “proper” copyright at all. I think what we really mean is more of an Open Source license. Regardless, this just covers source code. We haven’t even talked about a decompile. So, that’s Strike One.

Beyond this, an actual decompile wouldn’t decompile comments, and therefor the resulting code wouldn’t even contain the copyright message people are saying would cover it! Strike two.

To make matters worse, decompiled code looks nothing like the original code, so you can’t even compare the two and say that it is the same program. You would be saying “that’s my method or my setup or my system”. Well, as stated before, you can’t do that. A perfect example of this fact is Linux and Unix. Linux “copies” Unix is almost every fashion, but since it doesn’t actually use any of the CODE from the original Unix license (now owned by SCO) it is completely legal.

So, Strike Three, you are out. :D

Technically the only things that a copyright COULD cover would be published source code with the copyright notice in it (which is tenuous unless you take further steps), and a compiled EX4 file, which is considered a valid “form of material expression”.

Neither of these things cover a decompile. Seems wrong, doesn’t it? Not really, its just that a copyright isn’t really whats needed for a software program – a software license is.

That said – Your best bet to protect your work is two fold. Register the the source code copyright officially and if you publish it, note that it is a registered copyright with the US government. Heed the following advice from Wikipedia:

“While copyright in the United States automatically attaches upon the creation of an original work of authorship, registration with the Copyright Office puts a copyright holder in a better position if litigation arises over the copyright. A copyright holder desiring to register his or her copyright should do the following:

1. Obtain and complete appropriate form.
2. Prepare clear renditon of material being submitted for copyright
3. Send both documents to U.S. Copyright Office in Washington, D.C.”

And secondly, (and more importantly) if you want to distribute or sell your EA, your best protection is an End User License Agreement that specifically outlines the rights of the buyer, which would of course forbid copying, decompiling, reselling, etc.

As a side note on the EULA, I personally would never agree to a EULA on an EA, as the liability just isn’t worth it.

Hopefully that (more) than closes the topic. :)