Jump to content

Building your own EA G/08.


asgard2

Recommended Posts

Re: Building your own EA G/08.

 

Actually I've been working on an EA of my own for a while. It's based off the Steinitz Fractal Breakout indicator (except it doesn't rely on the indicators). It's hugely profitable... on any timeframe on any currency, except that I can't quite get the rules working right. I could use some help. Maybe I will borrow somew of the ideas introduced here.

 

Great stuff when you get it going, why don't you post a backtest or vid for us? So pleased to see someone doing something different.

 

We have a saying where I come from.. if you do what everyone else does, you will get what everyone else gets. If you do something outstanding, you will get what everyone else wants.

Link to comment
Share on other sites

  • Replies 189
  • Created
  • Last Reply

Top Posters In This Topic

Re: Building your own EA G/08.

 

Just curious what the overall trade strategy of your EA is now asgard. If you've ripped so mouch out of Greezley, what is left?

 

As for my own code experiment, I'm trying to clean it up. The stop loss and trailing stop doesn't seem to work properly. Lots of Ordertype errors when trying to close trades and move stoplosses). If I get super stuck, or if I get it working and it's unprofitable anyway (which I doubt. Some earlier version I had went to the upside in an insane fashion) I'll post the whole thing, but if not, well, too bad. ;)

 

My main issue is closing a trade at breakeven when the broker stoplimit is a bit tight. I'm trying to rummage through code of other EA to find a solid way of ensuring that a stop gets moved and a trade gets closed out -- WITHOUT any trade errors (or as few as slippage will allow), across 4-5 digit brokers and the possibility of NFP rules. That's my biggest issue.

 

The EA is not a scalper either... so spreads are not an issue, and so far the EA makes trades like a man possessed -- only that it's losing most of the time due to not closing the trades properly at the right time thanks to my own sloppy coding.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

I had to resurrect some of the Greezly code because I had too many pieces related that I didn't know about until I ran it through its tests. I found some functionally missing and one important part.. the Limit Distance wasn't working. I only used the high low limit for the logic though. The flat, iAC and speed indicators were gone.

 

here is the code that I used for my trailing stop.

 


extern double BuyTrailingStop               = 320;
extern double SellTrailingStop              = 380;     // How far into the trade the trailing stop should be set.
extern double StepTrailingStop              = 40; 


       if(BuyTrailingStop > 0)  total = OrdersTotal();
         {
          for(i = 0; i < total; i++){
          OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
          if(OrderSymbol() != Symbol())  continue;   //
          if(OrderType() == OP_BUY){
          if(Bid > (OrderOpenPrice() + Point * BuyTrailingStop)){
          if((OrderStopLoss() == 0) || (OrderStopLoss() < (Bid - Point * (BuyTrailingStop + StepTrailingStop)))){
          OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * BuyTrailingStop, OrderTakeProfit(), 0);}}}}
         }      
             
       if(SellTrailingStop > 0) total = OrdersTotal();
         {
          for(i = 0; i < total; i++){
          OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
          if(OrderSymbol() != Symbol())  continue;   //
          if(OrderType() == OP_SELL){       
          if(Ask < (OrderOpenPrice() - Point * SellTrailingStop)){
          if((OrderStopLoss() == 0) || (OrderStopLoss() > (Ask + Point * (SellTrailingStop + StepTrailingStop)))){
          OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * SellTrailingStop, OrderTakeProfit(), 0);}}}}
          } 

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Here is some break even code.. to change the digits on either lots of code, I just take remove a digit from the settings... e.g 600 on a five digit broker is 60 on a four digit broker.

 

BTW.. I am not sure this break-even code works I didn't try it.

 


    if(UseBreakeven)
  {
  for(int i=0;i<OrdersTotal();i++)
    {
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)        break;
     if(OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
     
     if(OrderType() == OP_BUY)
      
     if(breakeven>0)  
             {                
              if(Bid-OrderOpenPrice() > (Point*breakeven))
                {
                 if(OrderStopLoss() != OrderOpenPrice() && OrderStopLoss() < OrderOpenPrice())
                   {
                    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
                    //Print("Moved Buy to Breakeven");
                    return(0);
                   }
                }
             } 
                    
     if(OrderType()==OP_SELL)

     if(breakeven>0)  
             {                 
              if((OrderOpenPrice()-Ask)> (Point*breakeven))
                {
                 if(OrderStopLoss() != OrderOpenPrice() && OrderStopLoss() > OrderOpenPrice())
                   {
                    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
                    //Print("Moved Sell to Breakeven");
                    return(0);
                   }
                }
             }     
    } 
    }
    

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

to get rid of your errors..

 

paste these in to your EA under init

 

  
  if(TakeProfitB  != 0)  TakeProfitB  = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), TakeProfitB);
  if(TakeProfitS  != 0)  TakeProfitS  = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), TakeProfitS);
  if(StopLossB    != 0)  StopLossB    = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), StopLossB);
  if(StopLossS    != 0)  StopLossS    = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), StopLossS);

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Thanks for the tips. Yes, in fact I did rip that chunk of code from Greezley init to throw into my creation to ensure that the Trailingprofit was "normalized" against the broker market conditions. Trouble is, my EA doesn't actually use a take profit or stop loss. The process is dynamic based on calculated fibonacci retracements and an SMA and candle rules for a stop loss. This is what I'm having the most trouble with, as the calculations seem to come out wrong, and when they aren't, a lot of OrderSend errors prevent trades from closing when they should.

 

Very simple to convert 4-5 digit with stop loss and take profit in the init too, as it turns out:

 

if (Digits == 3 || Digits ==5)
{
   TakeProfit = Takeprofit * 10;
   Stoploss = Stoploss * 10;
}

 

At least I think that should work. 4 digit brokers have 4 digits, and 2 Digits (for JPY crosses), where as 5 digit brokers have 5 digits and 3 for JPY crosses.

 

The real cow is trying to have an EA that can play both sides of the fence on NFA rules.

 

My EA takes 3 trades in one direction with three different take profit levels per trade. This is easy when NFA is not an issue because you just set the TPs spereately, but when it IS an issue you have to force close the trades (in order they were created due to FIFO rules) when they pass your take profits. This usually means that the first and nearest take profit trade must be made first (as NFA rules prohibit you setting different TP levels for trades on the same symbol)... and obviously you cannot hedge either. Getting this to operate means that you have to be able to identify which trades are which, and in order to do that, you have to do some mumbo jumbo coding with the magic number.... such as create a numbering scheme.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

ok.. I am no coder but I am not sure why your code multiplies by 10..

 

the computer would see, for example say your stop-loss is set at 50 points. 50 * 10 is 500 where it needs to be (I would think) 50 * 0.0001 or 0.005 of the currency price.

 

Although it is hard to tell what else you have in there.. maybe it is possible it is seeing it as 500 times the base currency?

 

I have a bunch of snippets.. here is one that is complete and I believe would work for the calculations. Or you could just use *Point

 

int      digit=0;
double   point;


//+-------------------------------------------------------------------------------------------+
//| expert initialization function                                                            |
//+-------------------------------------------------------------------------------------------+

int init()
 {
//----

  if (Digits == 3 || Digits == 5) {
     if (Digits == 3)
        point = 0.01;
     else
        point = 0.0001;
  }
  else point = Point;

//----
  return(0);
 }
 
 //+-------------------------------------------------------------------------------------------+
//| expert start function                                                                     |
//+-------------------------------------------------------------------------------------------+

int start()
{
//----
digit  = MarketInfo(Symbol(),MODE_DIGITS);

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Rio why not move to a UK broker where hedging is enabled, it makes no sense to stay with a broker that limits your strategies ability to profit...

[spoiler:26ukmy10]Never trust, never fear, never beg[/spoiler:26ukmy10]
Link to comment
Share on other sites

Re: Building your own EA G/08.

 

I don't use any NFP brokers, so I don't have to worry about that. I was just experimenting on NFP demo accounts and wanted to add the functionality to see what is involved. If I get this EA up and running, I know for sure it will work a million times better on non NFP brokers.

 

Thanks for pointing out my error. Seems as if my problem with the stop loss was due to the calculation I was using. It is working much better now.

I still have to fix bits where some of my trades are getting stopped out at the wrong positions, for seemingly no reason. Once I fix this, we should see some interesting graphs because most of the stopped out trades were on course to be profitable.

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

Re: Building your own EA G/08.

 

Download the Greezly 2009 version here, I used google to translated it to engliish.

 

http://www.formulatrader.com/download/greezly2009.zip

 

what the EA need to be fixed?

1) the buy operation. some times has large Float DD. so the wrong buy operation need to be eliminated by using candelstick theory. code can be found in the svos EA.

as it, the relative DD is at 65.6%, too big. should be limited at 15% max.

 

2) the sell operation is not working well in the entire back test period. this shall be fixed.

 

Thanks Asgard for enlighting in the entire thread.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

The Sell is not working because of the following lines:

 

extern double BuyDenyLevel                  = 160;     // boundary level of opening orders BUY (above this level warrant can not be opened)
extern double SellDenyLevel                 = 155;     // boundary level of opening orders SELL (below this level orders can not be opened)

 

I believe the EA was initially tuned for the GBPJPY. These variables are used to set the price range for the pair to allow buy and sell orders to be placed. The EU would be in a much lower range (~100 times lower). Both of these can be set to 0 and the EA will not "deny" buying or selling based on price levels.

 

Hint: search for BuyDenyLevel in the code and you will see the deny levels are not used if set to 0.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

well, it took me a while to understand the greezly logic.

I have take away all the logic, such as

1) Accelerator indicator

2) Speed indicator

3) High Low limit

4) Flat indicator

and make it only fire the buystop.

 

and finally get the raw greezly EA logic, why Greezly EA fire orders at that price.

here is the picture describes the logic

link to the picture

http://www.formulatrader.com/download/bild/greezlyrawlogic.gif

http://www.formulatrader.com/download/bild/greezlyrawlogic.gif

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

finimej, Nice explaination and great idea about the buystoplevel. =D>

 

Seems to me you've integrated all asgard2's ideas.

 

However after I still can not 100% integrate all his ideas after tons of attempts, do you mind to send me your modified version please? [email protected], Very appreciated. ^:)^

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

qwertyasdf999

I am just in the begining where asgard was in the 2009-july or august.

I stripped off all the greezly logic, and find the buystoplevel is the simple entry rule. then I started to doubt if such simple entry rule works.

you can download all the code at http://www.formulatrader.com/download/GreezlyV1.6.zip with all the Greezly filter stripped. and no filter of candle added yet.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

I have made some observations that may help us progress more quickly.

 

1. The Acceleration indicator is only used to delete limit orders. It can be disabled by setting UseAcceleratorIndicator to 0.

2. The CountHighLowLimits is only used to delete stop orders. It can be disabled by setting CountHighLowLimits to 0.

3. The Speed indicator is used to delete limit orders and place market orders. It can be disabled by setting UseSpeedIndicator to 0.

If it is enabled by setting UseSpeedIndicator to 1, placement of market orders from the speed indicator can be dissabled by setting iSP_UseForOpenRealOrders to 0.

4. The Flat indicator places market orders. It can be disabled by setting UseFlatIndicator to 0.

5. Buy market, limit, and stop order placement can be disabled by setting UseBuy to 0 (or enabled by setting UseBuy to 1).

6. Sell market, limit, and stop order placement can be disabled by setting UseSell to 0 (or enabled by setting UseSell to 1).

7.The prices chosen for stop and limit orders are based on the current price level, i.e. if current price is 1.4532, the limit and stop orders are placed at 1.4500 + the level set by BuyStopLevel, SellStopLevel, BuyLimitLevel, and SellLimitLevel.

8. BuyStopLevel determines the Buy Stop order price. Placing of Buy Stop orders can be disabled by setting BuyStopLevel to -1.

9. SellStopLevel determines the Sell Stop order price. Placing of Sell Stop orders can be disabled by setting SellStopLevel to -1.

10. BuyLimitLevel determines the Buy Limit order price. Placing of Buy Limit orders can be disabled by setting BuyLimitLevel to -1.

11. SellLimitLevel determines the Sell Limit order price. Placing of Sell Limit orders can be disabled by setting SellLimitLevel to -1.

 

I will try to spend some time explaining more of the parameters. Any corrections to my explainations are most welcome. Thanks finemej and qwertyasdf999 for keeping this thread alive. As you may have determined, enabling the sell logic by setting SellDenyLevel to 0 did not improve the backtest results. The market conditions did not work well over the time period used by finemej for backtesting for this EA with the Sell logic enabled. Is it possible that separating the buy and sell logic/indicator parameters would improve the outcome?

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

well People, I thought this thread was dead..

 

Actually.. I did not get Greezly quite right and it failed on me sometime after my last post.

 

To tighten it up anymore was leaving me with a mediocre profit level, so I started a different one from scratch.

 

So far, so good.

 

Let me chase up the Greezly I modified and you can try it yourself.. If nothing else it was great for learning coding and trimming up my trading style.

 

For the last three posters here, if you want the new EA (no Name yet), I will upload it and PM you the address if you want it.

 

It is not finished but it has a few original ideas in the code.

 

I am running control points at this time because its still in development. The image is about 8 months of trading

 

http://img200.imageshack.us/img200/8120/7801.gif

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Nice to see you are still working on your ea's asgard! I've been working on my own creation for a whille now check it out, its not perfect yet and needs some internal adjustments but it is the closest i've come to holy grail :)) Lots are not limited or regulated since i like to see large numbers in the end of my backtests ...

This is january to september

http://i46.tinypic.com/30lc9qg.gif

 

Here is a link to backtest :)

http://www.multiupload.com/NW4HK7TP9U

[spoiler:26ukmy10]Never trust, never fear, never beg[/spoiler:26ukmy10]
Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Lots are not limited or regulated since i like to see large numbers in the end of my backtests ...

This is january to september

 

Hi Cyrillic.. looks like a great job.. LOL so how many lots is that? What pair do you run?

 

I only ever run maximum 8 lots.. I am not game enough

 

Actually.. I run this just to keep me safer :)

 

if (OrdersTotal() == 0) Risk=0.1;

if (OrdersTotal() == 1) Risk=0.2;

if (OrdersTotal() == 2) Risk=0.3;

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

Yup this is exactly what we all are aiming for.

It wasn't just gbp and eur that went nuts almost all usd corsses did it as well usd finally got some torque to rebound (plus European economic recovery plan was running out, thus that huge spike down on eur/chf a while ago) Anyway I will not stray off topic with meaningless fundamental analysis, i hope we can get more of the forum members on this forum inspired to build their own ea's!

[spoiler:26ukmy10]Never trust, never fear, never beg[/spoiler:26ukmy10]
Link to comment
Share on other sites

Re: Building your own EA G/08.

 

asgard2, Glad to have you back.

 

I always keep an eye on this thread. Sure I'd like to see your no-name EA.

 

please pm me the link. Thanks.

 

finimej, Thank you for your mql4 file, I back tested it for June and July, we have the same problem, I cant get rid of the two wrong orders placed on June 30th which eventually blew up my account.

I twisted High low limits part to avoid two wrong orders on 24 June.

I used your default setting btw.

Link to comment
Share on other sites

Re: Building your own EA G/08.

 

For those with the developing EA, full control point backtest here.

 

http://rapidshare.com/files/328262516/FxPro_-Real.rar

 

 

The EA needs more developing before it is a live proposition. It needs at least another month of work.

 

So far the logic only works on retracement but I will try going with the trend as well in separate logic

 

The sell logic is not added yet and the EA will not be complete until it is.

 

If you like it, I will keep you all posted on the progress

 

 

Edit: happy New Year to all.. hope you don't get too sick

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