⭐ birt Posted September 21, 2009 Report Share Posted September 21, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lukeye Posted September 21, 2009 Report Share Posted September 21, 2009 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 Quote Link to comment Share on other sites More sharing options...
IamJon Posted September 21, 2009 Report Share Posted September 21, 2009 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. Quote Link to comment Share on other sites More sharing options...
manganate Posted September 21, 2009 Report Share Posted September 21, 2009 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. :-? Quote When mind lingers in one place efficiency is lost Link to comment Share on other sites More sharing options...
Lukeye Posted September 21, 2009 Report Share Posted September 21, 2009 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 Quote Link to comment Share on other sites More sharing options...
⭐ birt Posted September 21, 2009 Report Share Posted September 21, 2009 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). Quote Link to comment Share on other sites More sharing options...
Lukeye Posted September 21, 2009 Report Share Posted September 21, 2009 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? Quote Link to comment Share on other sites More sharing options...
⭐ birt Posted September 21, 2009 Report Share Posted September 21, 2009 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?). Quote Link to comment Share on other sites More sharing options...
asgard2 Posted September 22, 2009 Author Report Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lukeye Posted September 22, 2009 Report Share Posted September 22, 2009 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 Quote Link to comment Share on other sites More sharing options...
Lukeye Posted September 22, 2009 Report Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lukeye Posted September 22, 2009 Report Share Posted September 22, 2009 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 ?? Quote Link to comment Share on other sites More sharing options...
Rio Posted September 22, 2009 Report Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lukeye Posted September 22, 2009 Report Share Posted September 22, 2009 Re: Building your own EA G/08. 8-) I managed to fix my last problem, took me 5 minutes. If I were a soccer player you could call me Diego now =)) Will do some backtests now. CU Quote Link to comment Share on other sites More sharing options...
IamJon Posted September 22, 2009 Report Share Posted September 22, 2009 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)); Quote Link to comment Share on other sites More sharing options...
Lukeye Posted September 22, 2009 Report Share Posted September 22, 2009 Re: Building your own EA G/08. Yes Jon, now i need a good idea on how to determine an 4hour Up or Downtrend. Backtest from 08.01.09 to 09.17.09 almost doubled the account. trades : 17 short:5 long:12 all winners And I need more trades :P Quote Link to comment Share on other sites More sharing options...
Lukeye Posted September 22, 2009 Report Share Posted September 22, 2009 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 . Quote Link to comment Share on other sites More sharing options...
asgard2 Posted September 22, 2009 Author Report Share Posted September 22, 2009 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 Quote Link to comment Share on other sites More sharing options...
IamJon Posted September 24, 2009 Report Share Posted September 24, 2009 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? Quote Link to comment Share on other sites More sharing options...
Stormin_Norman Posted September 24, 2009 Report Share Posted September 24, 2009 Re: Building your own EA G/08. try the nolagMA indicator. Quote "It is inconceivable that anyone will divulge a truly effective get-rich scheme for the price of a book." Victor Niederhoffer (1943–), US hedge fund manager and statistician Link to comment Share on other sites More sharing options...
IamJon Posted September 25, 2009 Report Share Posted September 25, 2009 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 Quote Link to comment Share on other sites More sharing options...
asgard2 Posted September 25, 2009 Author Report Share Posted September 25, 2009 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. Quote Link to comment Share on other sites More sharing options...
IamJon Posted September 25, 2009 Report Share Posted September 25, 2009 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? Quote Link to comment Share on other sites More sharing options...
asgard2 Posted September 25, 2009 Author Report Share Posted September 25, 2009 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 Quote Link to comment Share on other sites More sharing options...
asgard2 Posted September 25, 2009 Author Report Share Posted September 25, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.