Jump to content

Building your own EA G/08.


asgard2

Recommended Posts

Hello People,

 

I am starting this thread because I have had so many PMs wanting to purchase my EA.

 

Here is the video link of it .. http://rapid*share.com/files/281613188/TradeDemo.rar

 

This is the discussion so far...http://indo-investasi.com/viewtopic.php?f=6&t=5559&start=0

 

I did not build it to sell it and it is not for sale. I posted about it because you can all do it too and that was my point. I am happy to help.

 

I am no coder (so don't give me a hard time) but the time I invested is paying dividends.

 

If you want to do it yourself.. this is the first piece of code I added. You can just cut and paste it in.

 

//paste this with your other variables
extern bool UseDeferOrderTimeout          =1; 
extern double StopResetMinutes              =14;

if( UseDeferOrderTimeout >0)  //this piece of code deletes the order
  {
     total = OrdersTotal();
    
     if(total>0)

      for(i = total - 1; i >= 0; i--)
     {
        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
        
        if(OrderType()==OP_SELLSTOP && OrderSymbol()==Symbol())
        {
           if((TimeCurrent() - OrderOpenTime()) > StopResetMinutes * 60 )
           {
              if(PrintComments)  Print("Sell Stop Deleted.");
                       OrderDelete(OrderTicket());
           }
        }
     }
  }

 

That is a start and it will change the way it trades.. now you need to figure out.. a time delay between the deleted orders.

 

you can help each other.. if you do, then I will post some more code.

 

Now, I will warn you.. it actually took me many many hours and it is not finished. If you are not a coder, don't expect to finish anytime soon.

 

Edit: don't know what I was thinking "UseDeferOrderTimeout" is bool .. I have corrected it now

Link to comment
Share on other sites

  • Replies 189
  • Created
  • Last Reply

Top Posters In This Topic

Re: Building your own EA G/08.

 

These are some of the rules I added to my best EA

1) trade hour

2) if trade is in profit at trade hour close and no sl, set intrim trailing at break even.

3) if trade is not in profit at trade hour close, then close trade at first break even.

4) Don't use limit or instant execution orders

5) delete unused buystop every 14 minutes

6) if 5 is true, then don't reorder for 45 minutes.

7) Minimum Time between real orders 30 minutes

8) If MA crossing is higher than trailing stop, then take profit now.

9) Dynamic stop loss.. works on speed indicator and iAC

10) If buystop is taken out buy a spike close order now.

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

12) Don't trade the NFP

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

14) If trade is one hour old and has reached 14 pips twice and is now 14 pips down, close at next break even and sleep 16 minutes.

 

 

Hello asgard2,

 

First of all, thank you for the sharing! :-bd

 

above list is from your post on another thread, can I check if the above code is referring to one of the list mentioned.

 

- do you have coding on adding on some filters, e.g MA filters or filter from another indicator.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

 

Hello asgard2,

 

First of all, thank you for the sharing! :-bd

 

above list is from your post on another thread, can I check if the above code is referring to one of the list mentioned.

 

- do you have coding on adding on some filters, e.g MA filters or filter from another indicator.

 

I do mate... however, I really want people to be helping each other. More ideas, better code and a better EA will be the result.

 

If I post all the code, I may as well post the EA and no one will learn anything.

 

if we get some active people trying to do something, others who have no clue (like me a short time ago) will be able to follow and learn.

 

Even though this is the best EA I have seen, some people will go on to make other EAs that will be far better than this one.

 

Thats my plan anyway :)

 

I am really down on the commercial EA's. Most are just a rip off of someone else's EA that they ask you to buy.

 

No Commercial EAs that I know of are profitable although many could be. Its time to change the whole ripping people off system. Idealist?.. Yup!

 

Greezly gave his EA away after the championships was over. That is why the source is available. Kudos to him, what a trooper!

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Hmm.. not sure what happened there but here it is again

 

http://rapid*share.com/files/281613188/TradeDemo.rar

 

Hello asgard2,

 

Thanks for the kind action. Sorry to ask again, as I keep having "The download session has expired" message. Is it possible to request for the upload to 4shared?

 

Thanks.

 

Regards,

Collin

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

 

Hello asgard2,

 

Thanks for the kind action. Sorry to ask again, as I keep having "The download session has expired" message. Is it possible to request for the upload to 4sh@red?

 

Thanks.

 

Regards,

Collin

 

Its working now (I checked this minute).. you need to remove the asterisk from the address.

 

I don't have a 4shared account.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

 

Change Inputs

BuyLimitLevel and

SellLimitLevel to -1

 

correct ?

 

Could be, I only use it on a 5 digit broker (because I am having trouble with 4)

 

I stopped the limit orders by setting them to 1200.

It doesn't try to order then. That was a while back and I have been so busy with the rest of it, I never bothered investigating

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Here you go people,

 

If you put this code in just after start.. you will find visual testing easier and if you change the version each time you update you will be able to keep track of which version traded which way.

 


  double free=AccountFreeMargin();
  Comment("\n", "Your Version here", "\n", "Account free margin is ",DoubleToStr(free,2),"\n","Current time is ",TimeToStr(TimeCurrent()));
//-----------------------------------------------------------------------------------------------------------------------------------------  

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Here you go people,

 

If you put this code in just after start.. you will find visual testing easier and if you change the version each time you update you will be able to keep track of which version traded which way.

 


  double free=AccountFreeMargin();
  Comment("\n", "Your Version here", "\n", "Account free margin is ",DoubleToStr(free,2),"\n","Current time is ",TimeToStr(TimeCurrent()));
//-----------------------------------------------------------------------------------------------------------------------------------------  

Thanks. I understand that you are trying to help with these code snippets, but this one is purely cosmetic and, imo, does not really say anything much about your approach. A more "meaty" content probably will be appreciated. ;)

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Thanks. I understand that you are trying to help with these code snippets, but this one is purely cosmetic and, imo, does not really say anything much about your approach. A more "meaty" content probably will be appreciated. ;)

 

Hmm..

 

Not everyone can code. Some might like to make an EA and this is a good start for them.

 

The last piece of code is posted to aid visual testing. Not everyone knows about it.

 

so far there is a list of proven improvements, a video demonstrating trading style, the EAs and the most crucial piece of the code.

 

If someone can already code they don't need me. Its already there.

 

For those that cannot code, I will post more when I at least see people are trying to do this themselves.

 

This is not supposed to be a giveaway, if no one wants to help each other.. then why would I?

 

Some here might like the opportunity to lean something that will benefit them well beyond the scope of this EA.

 

So, anyone wants me to post more code.. solve one of the problems and post the code for others to share.

 

Right now, I suggest someone post the other half of the order deletion. Meaning after a buystop order is deleted there has to be a delay before the next one.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Hi there,

 

I'm glad we have now have this thread we can share our ideas and improvements.

 

Sadly observe still no serious coders are here (except of Clovelly who is also fun of coding), but I think I know what is the problem.

 

This work will (I'm sure) lead to nice profitable EA and some people will be reading it, observing how EA develops.

 

Others consider their experince should stay with them, they rather ask people to pay them money (so called "professional coders") rather than help to improve something potentially profitable on a free basis. I would say these are "pros" for money, but they will also gladly leech ideas from this thread as well.

 

And there are beginning coders who eager to learn and share not so wide experience, I trust there will be enough such guys.

 

And I'm sure we can work w/o code published in full here. Original Greezly EA was posted in a thread "Before buying an Expert Advisor" so interacting in a way it's now is pretty okay if one is willing to work on EA improvement and not simply leech.

 

 

On this one:

 

//paste this with your other variables
extern bool UseDeferOrderTimeout          =1; 
extern double StopResetMinutes              =14;

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

 if (UseDeferOrderTimeout == 1) // paste these next set of lines somewhere in the code. I pasted it under TimeStoplosseMinutes
  {
       if((TimeCurrent() - OrderOpenTime()) /60 >= StopResetMinutes)
     {
        glDeleteAllDeferOrders(_OP_BUYSTOP, Symbol());
        glDeleteAllDeferOrders(_OP_BUYLIMIT, Symbol());
        glDeleteAllDeferOrders(_OP_SELLSTOP, Symbol());
        glDeleteAllDeferOrders(_OP_SELLLIMIT, Symbol());
        
     }
 }

 

Edit: don't know what I was thinking "UseDeferOrderTimeout" is bool .. I have corrected it now

 

 

It's advisable and a very good practice to set Integer variables instead of Boolean to enable qucker optimization.

 

So in Strategy tester you can opt to enable this feature on disable by simply optimizing from 0 (disabled) to 1 (enabled).

 

So I suggest UseDeferOrderTimeout be Integer and use this piece of code:

 

extern int UseDeferOrderTimeout          =1; 

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

OK.. now about the sell side of Greezly

 

I believe the original code was this.. found it in an older version

 



double _BuyDenyLevel;
double _SellDenyLevel;
_BuyDenyLevel = (BuyDenyLevel * _Point);
_SellDenyLevel = (SellDenyLevel * _Point); 


  if(type == _OP_BUY)
  {
     if(UseBuy == 0)  return(false);   
     if((_OrderType == OP_BUY) && (OpenRealOrders == 0))  return(false);   
     if((BuyDenyLevel !=0) && (_OrderOpenPrice >= _BuyDenyLevel))  return(false);   
  }
  
  if(type == _OP_SELL)
  {
     if(UseSell == 0)  return(false);   
     if((_OrderType == OP_SELL) && (OpenRealOrders == 0))  return(false);   
     if((SellDenyLevel !=0) && (_OrderOpenPrice <= _SellDenyLevel))  return(false);   
  }
  

 

The orignal code was modified to this by someone..

 

  if(type == _OP_BUY)
  {
     if(UseBuy == 0)  return(false);   
     if((_OrderType == OP_BUY) && (OpenRealOrders == 0))  return(false);   
     if((BuyDenyLevel !=0) && (_OrderOpenPrice >= BuyDenyLevel))  return(false);   
  }
  
  if(type == _OP_SELL)
  {
     if(UseSell == 0)  return(false);   
     if((_OrderType == OP_SELL) && (OpenRealOrders == 0))  return(false);   
     if((SellDenyLevel !=0) && (_OrderOpenPrice <= SellDenyLevel))  return(false);   
  }

 

To make it sell on any currency other than the Japanese Yen.. you need to lower the sell deny level to zero or not much more.

 

If you are going to use the sell logic you will need to change it or.. you need to put in some pretty severe rules to stop it taking over the buy logic.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

OK.. now about the sell side of Greezly

The orignal code was modified to this by someone..

 

  if(type == _OP_BUY)
  {
     if(UseBuy == 0)  return(false);   
     if((_OrderType == OP_BUY) && (OpenRealOrders == 0))  return(false);   
     if((BuyDenyLevel !=0) && (_OrderOpenPrice >= BuyDenyLevel))  return(false);   
  }
  
  if(type == _OP_SELL)
  {
     if(UseSell == 0)  return(false);   
     if((_OrderType == OP_SELL) && (OpenRealOrders == 0))  return(false);   
     if((SellDenyLevel !=0) && (_OrderOpenPrice <= SellDenyLevel))  return(false);   
  }

 

To make it sell on any currency other than the Japanese Yen.. you need to lower the sell deny level to zero or not much more.

 

If you are going to use the sell logic you will need to change it or.. you need to put in some pretty severe rules to stop it taking over the buy logic.

Relatively the old and new codes are the same, the old DenyLevels are the prices in pip values and new ones are the actual price values. They are just a matter of settings.

 

That similarity aside, these Deny Levels are fixed by settings, to prevent from buying too high or selling too low. But as they are static absolute values, it is a case of all-or-nothing settings. In the demo video, the BuyDenyLevel is set at 160, so ALL buy trades are allowed as the Ask prices never exceed 160 (except for some JPY pairs); and the SellDenyLevel is set at 155, effectively blocking ALL sell trades (except, again, some JPY pairs). So the simplistic static settings are not correct, and should be changed to cater for each pair dynamics.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

 

To make it sell on any currency other than the Japanese Yen.. you need to lower the sell deny level to zero or not much more.

 

If you are going to use the sell logic you will need to change it or.. you need to put in some pretty severe rules to stop it taking over the buy logic.

Relatively the old and new codes are the same, the old DenyLevels are the prices in pip values and new ones are the actual price values. They are just a matter of settings.

 

That similarity aside, these Deny Levels are fixed by settings, to prevent from buying too high or selling too low. But as they are static absolute values, it is a case of all-or-nothing settings. In the demo video, the BuyDenyLevel is set at 160, so ALL buy trades are allowed as the Ask prices never exceed 160 (except for some JPY pairs); and the SellDenyLevel is set at 155, effectively blocking ALL sell trades (except, again, some JPY pairs). So the simplistic static settings are not correct, and should be changed to cater for each pair dynamics.

 

 

Good for you Mate.. well done.

 

Suggestions?

 

I think sell settings and buy settings are never the same.. I have split most of the code in two, so I can optimize on both.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

:shand: many thanks asgard2 can a EA be made from renko bars I have a 3pip & 10pip templates renko script which i have in expert adviser instead of scripts folder works better & indicator I place on template-- 1st. I must open m1 chart place renko script on it then open offline 2m chart & place template & indicator there -- =D>

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Ok Mate..

 

Sounds like you tried pretty hard.

 

This is the first piece of code I wrote.. it works but it is not really right.

 

The reason it is not right is because it tells the EA.. go through the history, count backwards and select by position the time the last order. Actually the order could be anything (not that it is likely to be anything else). It needs to select the order based on the comment. The comment will be "cancelled"

 

I tried to do that but the code never worked and I could not find anyone that knew how to do it.. so this works, it could just be better.

 

If anyone that can code better than me feels like helping.. that's great, else I have no problems with this.

 


extern int NextBuyStop_Order_Minutes   =46; //put this line with your other variables


//---------------------------------------------------------------------------------Put this block of code under this line "MayOpenDeferOrder = true;"
if ((type == _OP_BUY) && (MayOpenDeferOrder && NextBuyStop_Order_Minutes !=0)) 
        
         {
        total = OrdersHistoryTotal();

           for(e = total - 1; e >= 0; e--)
              {
              OrderSelect(e, SELECT_BY_POS,MODE_HISTORY);
        
           if(OrderSymbol() != Symbol())  continue;   
              {
              if(((TimeCurrent() - OrderOpenTime())/60) < NextBuyStop_Order_Minutes) MayOpenDeferOrder = false; 
              break;
        }
     }
  } 

 

Now you see that code.. you should be able to write the on for the sell side.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

You could try this with a magic number..

 

It is not my priority now.. but I think this should work.. why dont you test it and let us all know

 


       
      if ((type == _OP_SELL) && (MayOpenDeferOrder && NextSellStop_Order_Minutes !=0))//Time Delay for the next Buy Stop Order
        
         {
        total = OrdersHistoryTotal();

           for(e = total - 1; e >= 0; e--)
              {
              OrderSelect(e, SELECT_BY_POS,MODE_HISTORY);
        
           if ((MN_Usual == OrderMagicNumber())&& (Symbol() == OrderSymbol()))  continue;  
              {
              if(((TimeCurrent() - OrderOpenTime())/60) < NextSellStop_Order_Minutes) MayOpenDeferOrder = false; 
              break;
        }
     }
  } 

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

HMM....

 

tried the first one but tester says :

 

'e' - variable not defined ??

 

ok.. just put a line there under the if statement that defines e as an interger

 

like

 

int e;

 

Did you go through the mql4 tutorials? If not.. here is a link, I just uploaded them.

 

http://rapidshare.com/files/282126164/mql_lessons.rar

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...