Ema Cross! - page 20

 

EMA cross tester

Hi Codersguru!

I want to first start by thanking you for the awesome MT learning courses. Without them, I don't know how i would have learned mql as fast. You are the MAN!!

Recently, I have been programming ea's to be able to trade in a mulititude of different ways so that i am able to test ea's on a live account while having multiple settings running on the same pair and same TF. I love the EMA idea ,and I coded an EA that uses your criteria. This version will be able to trade almost unlimited instance of the EA with different settings on same TF/PAIR or any combination. The program sets a GlobalVariable in MT and uses it to create a unique ID which is then inserted into the comment of opened trades. The EA then processes orders based on this unique ID.

In addition, I added a function to write a csv file that resembles a trade statement that includes the settings which were in place at the time of testing (expert/files folder). After trading this way there will be a lot of trades from all the different EA's so essentially this is where you go to get the accurate trade stmnts.

Out of the box, it should function just like V2. There are some extra features that I added in case someone wants to go live.

I appreciate everything, and I'm curious to see what your thoughts are on this one!

Nic

 
hellkas:
Hi Hendrick

Could u please tell me your settings and TF..

Thank you

Hi Hellkas,

These are my pairs (Timeframe for all pairs is Day)

USDJPY, EURCHF, AUDUSD, EURAUD, USDCAD, USDCHF, AUDCAD, EURCHF.

Settings: default; except Reversal=True and Lots=0,1

Greetings!

 
Nicholishen:
Hi Codersguru!

The program sets a GlobalVariable in MT and uses it to create a unique ID which is then inserted into the comment of opened trades. The EA then processes orders based on this unique ID.

Nic

Nic

This is a great way to track your orders and any seperate files your EA may create, again shows your ability see things others may not. The reason I'am writing is that I did the same thing, using the OrderComment() to label trades and found it posed future problem. In that;

1) the comment field is a string parameter, to which your broker may append their own comments to it. when your order is closed with take profit or a stop loss being hit for example, the broker will append a message to your comment field. If your not aware of this it could cause some errors in the future if you access your account trade history using your original comment not knowing that it was appended too. also if an order is expaired your comments are rewriten altogether with a brokers message.

2) The GlobalVariable() function is of type double number. which gets converted to type string when used as your OrderComment input. Mixing variable types is not a good programing habit to get into as this could cause future variable mixmatch errors if you go back to alter your code.

To get away from the above I used the MagicNumber feild of the OrderSend() function. The code below is the function call I use to generate a unique number that is used as you discribed, for order traceing and record keeping. It will generate a number from 100 to 999. Once the number is used the new number is incremented by one for the next EA to use. If you place the call to this function in the init() function area of your code it gets seen only once at start up and will stay with your EA till its turned off.

Example;

int OrderID = 0;

int init() {

OrderID = GetTagNumber()

...

...

...

return( 0 );

} // End init, function:

You can then use the OrderID were ever you want to label your trades, files entries etc..

//«« <<<>>> »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»

int

GetTagNumber() { // Sets the SystemTag To....

int PullNumber = 0;

if( GlobalVariableCheck( "PullTag ( Do Not Delete )" ) ) {

PullNumber = GlobalVariableGet( "PullTag ( Do Not Delete )" );

} else {

PullNumber = 100;

} // End If, GlobalVariableCheck:

GlobalVariableSet( "PullTag ( Do Not Delete )", PullNumber + 1 );

if( GlobalVariableGet( "PullTag ( Do Not Delete )" ) > 999 ) {

GlobalVariableSet( "PullTag ( Do Not Delete )", 100 );

} // End If, GlobalVariableSet:

return( PullNumber );

} // End Function, GetTagNumber:

The OrderID variable has to be declared outside of the init() function so the rest of your program will be able to see its value.

You can change the lower and upper limits (100 - 999) to what ever you want or remove the upper limit and it will keep on increasing without resetting.

The reason for the variable name ... "PullTag ( Do Not Delete )" ... is because you can now view and delete the global variables out side of the EA. The do not delete is a warning message that shows up when viewing your global variables. If you delete the PullTag variable it will restart at 100 again on the next EA startup. GlobalVariables retain there value even when you turn off your work station.

The CockeyedCowboy

Like always I say too much.

 

...just as I was wondering why the SL/TP weren't showing up in history. Thanks for the insight! I will incorporate this into my code. Thanks so much for being such a valuable resource!!

 

Nic

If you open up your trade terminal window and click on account history tab,> right click on any area of the terminal,> click on menu label> comments. You will be able to view your comments and any appended comments from your broker (They are usally within [ .... ] ) within your terminal window.

The CockeyedCowboy

 

Yeah... I noticed that all of the TP/SL are appended as [tp][sl]. I like your code better.

 

what happen coders guru? what happen ? I down load your last Version of ema cross ea at post 369 ,you see what happen with the test grv but tell me why

Files:
1_4.gif  8 kb
 

Guys please,

help me with something. Why the REVERSAL option is included in this EA? I just do not get why trade agains the point of both EMA cross...

Thanks...

So far with REVERSAL true = I ve earn more than 100 pips but it is crazy. I mean when the EMA cross point appaers, this EA will open absolutely opposite trade so you will lose money...

 

pro-trend vs counter-trend

glader:
Guys please,

help me with something. Why the REVERSAL option is included in this EA? I just do not get why trade agains the point of both EMA cross...

Thanks...

So far with REVERSAL true = I ve earn more than 100 pips but it is crazy. I mean when the EMA cross point appaers, this EA will open absolutely opposite trade so you will lose money...

Well, you can choose to work pro-trend.

IMHO, in the counter-trend we open the position at the best price and bear some losses at the beginning then we gain the maximum amount we could gain!

 

insufficient data!

Audio:
what happen coders guru? what happen ? I down load your last Version of ema cross ea at post 369 ,you see what happen with the test grv but tell me why

Audio,

Please don't cry .

I think you don't have enough history data.

Give my back test and forward test a look !

Files: