Jump to content

Building your own EA G/08.


asgard2

Recommended Posts

Re: Building your own EA G/08.

 

if((UseTradeHourClose ==true)&& ((TimeHour(TimeCurrent())< FromHourTrade+GMTOffSet || TimeHour(TimeCurrent()) >= ToHourTrade+GMTOffSet)))MayOpenDeferOrder = false;

 

This line works for me.

 

It only happens to work with the values you're currently using.

 

Ask yourself:

1. What happens if the GMT offset is like +10?

2. What happens if you want it to trade from 22 to 02 with GMT offset 0?

 

You can even try those values and notice how and why it doesn't work correctly.

Link to comment
Share on other sites

  • Replies 189
  • Created
  • Last Reply

Top Posters In This Topic

Re: Building your own EA G/08.

 

Yes birt i found out already

 

Ask yourself:

1. What happens if the GMT offset is like +10?

2. What happens if you want it to trade from 22 to 02 with GMT offset 0?

 

I will get different dates , so i posted

This line works for me.

 

On mql4 site I found a function but I tell you, for a beginner like me it is way too much . :-/

It is on my todo-list but at the very bottom ! #:-S

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Hello All,

 

I just found this thread and would like to be a contributor. I have many years of programming experience, Just not any with MQL. I can count the number of lines of MQL I have written on 1 hand. Also if one of you could instruct me as to how to stop all the buddy tv and crackle, etc. I would be able to go through these threads a little faster and help out more.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

if((UseTradeHourClose ==true)&& ((TimeHour(TimeCurrent())< FromHourTrade+GMTOffSet || TimeHour(TimeCurrent()) >= ToHourTrade+GMTOffSet)))MayOpenDeferOrder = false;

 

This line works for me.

 

It only happens to work with the values you're currently using.

 

Ask yourself:

1. What happens if the GMT offset is like +10?

2. What happens if you want it to trade from 22 to 02 with GMT offset 0?

 

You can even try those values and notice how and why it doesn't work correctly.

 

This is a good example of the need for a debugger and IDE in MT4. I hope MT5 (and MQL5) is up to it. :-?

When mind lingers in one place efficiency is lost
Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Today I made some backtests with different brokers.

 

At 4 digit broker everything looks good so far .

At 5 digit broker I get alot 'OrderSend error 130' for Sellstop and Buystop orders.

 

Backtest from 2009.06.01 to 2009.08.05

4 Digit : total trades 68

shorttrades 34

longtrades 34

 

5 Digit : total trades 24

shorttrades 24

longtrades 0

 

HMMM....

 

I need a break

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

At 5 digit broker I get alot 'OrderSend error 130' for Sellstop and Buystop orders.

 

You're probably not using the correct point value for those orders. For sellstop/buystop orders you get that error when placing the order too close to the current market value. If, however, you are using the correct point value, make sure the orders are at a minimum distance of MarketInfo(Symbol(),MODE_STOPLEVEL).

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

I'm not familiar at all with Greezly so I'm not sure I can help you much, but it's probably a Point issue. Taking a quick look at the source code, I recommend looking at all the glDeleteAllDeferOrders calls and identifying the culprit. It's most likely one of those where _Point is used (by the way, are you adjusting _Point for the 5 digit brokers?).

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Hey birt,

 

all errors are gone =D> thank you

 

But I have another problem only on 5 digit broker .

Buystop and sellstop orders are deleted in the same minute they were opened.I have no idea why ?

 

Anyone?

 

Lukeye, you will probably have a missing bracket or a bracket } in the wrong place.

 

Quickest way to find it is just copy each of your changes back into the original until you find which piece of code is doing it.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

My idea was to have two copys with hardcoded variables, one for 4digit and one for 5digit broker.

I changed too many of them at once and got lost.

Backtests look good so far but I need a filter to avoid selling at the beginning of an uptrend and vice versa.

 

I will be back in some hours maybe I find a solution myself :huh:

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

extern int UseMAIndicator =1;

 

//-----13) Don't buy on 4hr downtrend, don't sell on 4hr uptrend.--------------

 

if(UseMAIndicator==1)

{

double MaBig,MaSmall;

bool IsCrossDown,IsCrossUp;

 

MaBig=iMA(NULL,0,100,0,MODE_EMA,PRICE_CLOSE,0);

MaSmall=iMA(NULL,0,40,0,MODE_EMA,PRICE_CLOSE,0);

 

IsCrossDown=(MaSmall<MaBig);

IsCrossUp =(MaSmall>MaBig);

 

if(IsCrossDown==true)

{

glDeleteAllDeferOrders(_OP_BUYSTOP, Symbol());

glDeleteAllDeferOrders(_OP_BUYLIMIT, Symbol());

 

 

}

if(IsCrossUp==true)

{

 

glDeleteAllDeferOrders(_OP_SELLSTOP, Symbol());

glDeleteAllDeferOrders(_OP_SELLLIMIT, Symbol());

 

 

 

}

 

}

 

//-----------------------------------------------------------------------------

 

Like this it deletes sellstop orders in an uptrend, but I want the EA not to open sellstop orders in an uptrend.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

I added two rows :

 

if(IsCrossDown==true)

{

glDeleteAllDeferOrders(_OP_BUYSTOP, Symbol());

glDeleteAllDeferOrders(_OP_BUYLIMIT, Symbol());

 

IsCrossDown=false;

}

if(IsCrossUp==true)

{

 

glDeleteAllDeferOrders(_OP_SELLSTOP, Symbol());

glDeleteAllDeferOrders(_OP_SELLLIMIT, Symbol());

 

 

IsCrossUp=false;

}

 

Have to go to work now.

Anyone willing to participate ??

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

extern bool   UseMA_TakeProfit              = false;  // Confirmation of trend
extern double ShortEma                      = 5;

 

I think there is another extern variable required.

 

I really don't have time to work on this now. I spent some time today reverse engineering maybe a third of Greezley. I am not skilled at this and it's going to tak eme quite some time... but I really want to figure this out.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

The MA cross doesn't tell you the longer term trend. It tells you how the shorter term trend compairs to the longer term. You only need the slope of the long MA. The current bar is always fluctuating so I would consider the following:

 

Slope=(iMA(NULL,0,100,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,100,0,MODE_EMA,PRICE_CLOSE,2));

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Hello asgard,

 

can you explain what you mean by this:

11) Divide buy and sell. inc stop order level, take profit, trailing stops, trailing steps, and indicator parameters.

 

My english is bad and I have no idea .

 

Buy and Sell settings will not be the same.. you need to separate them. "Divide the Settings" = "split the settings in half"

 

Correction,... I did not do it with the trailing step

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

asgard2, Lukeye,

 

It has been tougher determining the slope of the H4 trend than I thought. The longer term H4 trend may follow a channel while the short term for a day or more may go counter to the channel or even flat. The double EMA cross suffers from lag when the EMAs are sufficient in length to follow the channel and not chatter from the short term fluctuations as does the slope. I have looked at a few other indicators and am not comfortable yet. Are we trying to avoid trading counter to the channel or just counter to the shorter term?

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Stormin,

 

Thanks for the advice. I have been experimenting with the nonlagMA with another trading system. It may be a good fit. I guess I need to understand what I am trying to accomplish a little better.

 

Thanks for the help. Any other advise would also be appreciated.

 

Jon

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

asgard2, Lukeye,

 

It has been tougher determining the slope of the H4 trend than I thought. The longer term H4 trend may follow a channel while the short term for a day or more may go counter to the channel or even flat. The double EMA cross suffers from lag when the EMAs are sufficient in length to follow the channel and not chatter from the short term fluctuations as does the slope. I have looked at a few other indicators and am not comfortable yet. Are we trying to avoid trading counter to the channel or just counter to the shorter term?

 

I originally worked against the EA.. tried to implement rules to stop it buy when there was a significant drop in the market over x period but when I watched it trade it was no good.

 

I then decided to go with it and let it fall. I did this will a five minute chart.. even though the video shows a 15 minute chart.

 

My drop protection says.. if the market drops less than 60 pips in the last 5 minutes a buy is allowed. If it drops more, close all trades and sleep. I found that to be a pretty good figure.

 

My Trend rule works on the lows only.. count bars(lowsOnly) If lows are getting lower..don't buy, else if lows are getting closer with x pips a buy is allowed (this is the 15M chart). I does not use moving averages, although it could. Since I was just a beginner when I wrote it, I had no idea how to write code using indicators and that was the best I could come up with. I found an angle indicator to measure the angle of the lows and that was what I wanted but it was too complex for me to use. This is it here

 

h**p://www.forex-tsd.com/attachments/ema-cross/25634d1171506195-if-34-ema-line-flat-do-not-take-signals-market-chop-ema_angle.mq4

 

Since most large drops, follow with a slower downtrend my two rules work together.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

asgard2,

 

Thanks. I will take a look at it. 60 pips in 5 minutes is a big drop. Only a significant news news event would cause such a move. It looks like your thoughts were with respect to the short term trend. Is the thought that if there has been a significant drop over the last 4 hours, don't buy and If there has been a significant rise in the last 4 hours, don't sell?

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

asgard2,

 

Thanks. I will take a look at it. 60 pips in 5 minutes is a big drop. Only a significant news news event would cause such a move. It looks like your thoughts were with respect to the short term trend. Is the thought that if there has been a significant drop over the last 4 hours, don't buy and If there has been a significant rise in the last 4 hours, don't sell?

 

Hmm.. I will grab a pic and post it so you can see what I mean.

 

Not that it was real it was just a test for the NFP but it will server the purpose for demonstration

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

asgard2,

 

The only way I have ever been able to get the sell logic to work at any halfway respectable level is to leave it the sell deny level at 160 and put this rule in. That was way back in my first version

 


if(MayOpenDeferOrder)
    {                     
       if((type == _OP_BUY) && ((iOpen(NULL,PERIOD_H4,1)> iClose(NULL,PERIOD_H4,1))&& (iOpen(NULL,PERIOD_H1,1)> (iClose(NULL,PERIOD_H1,1)+TrendPips * 0.0001))))  MayOpenDeferOrder = false;
     }

 

Ultimately while it somehow activated the sell (don't ask, I have no clue why).. it was not more profitable. The rule was canned! Trendpips, just gave me a figure to optimise on for testing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...