Can somebody help me?

[Deleted]  

Hi,

I was wondering if anyone could help me write an EA for a strategy that I've been messing around for a while.

It's an "always-in" strategy where you go long when the 6-period EMA of close crosses above the 7-period EMA of open. You close the position and go short when the 6-period EMA of close crosses below the 7-period EMA of open.

There'll be a safety stop loss of 1.5 (can be parameter) ATR from the entry. Position size is determined by stop loss where each trade would not risk more than 2% (can be parameter) of account.

This strategy has been fairly successful for me and would love to be able to test it on historical data.

Thanks

Terence

[Deleted]  

Define your use of the word "help".


CB

 
This strategy won't work. EMA6 crosses EMA7 frequently in horizontal trends, results in evaporation of Equity.
[Deleted]  

cloudbreaker: As in, can somebody write it for me. Won't take you too much time.

barisyidiz1982: It doesn't cross that frequently cos one is of the open while the other is of the close. I'm talking about waiting till the end of each bar before placing a trade on the open of the next.

[Deleted]  
chubbyme:

cloudbreaker: As in, can somebody write it for me. Won't take you too much time.

barisyidiz1982: It doesn't cross that frequently cos one is of the open while the other is of the close. I'm talking about waiting till the end of each bar before placing a trade on the open of the next.

What do you define as not too much time? How have you arrived at this estimate?

And what rate are you offering?


CB

[Deleted]  
www.getyourea.com
[Deleted]  

Here it is.

it took me about 15 minutes.

//+------------------------------------------------------------------+
//|                                                     WierdEMA.mq4 |
//|                                                        Tal Perry |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Tal Perry"
#property link      ""
extern double Risk_Level =0.002, SL=1.5;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

double MaClose (int speed)
   {
     return (NormalizeDouble( iMA (Symbol(),0,speed,0, MODE_EMA, PRICE_CLOSE,0),Digits ) );
   }   

double MaOpen (int speed)
   {
     return (NormalizeDouble( iMA (Symbol(),0,speed,0, MODE_EMA, PRICE_OPEN,0),Digits ) );
   }   
   



int start()
  {
  int i;
  double Lots, Stop;
  static double MaxLoss;
  MaxLoss = (AccountBalance() * Risk_Level ) * MarketInfo( Symbol(), MODE_POINT); 
   if (MaClose(6) > MaOpen(7))
   {
   
   //  CLOSE SHORTS
   if (OrdersTotal()> 0)
   {
   
      for (i=0; i<OrdersTotal(); i++)
         {
            OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
            if (OrderType() == OP_SELL)
               OrderClose(OrderTicket(),OrderLots(),Ask,5);
         }      
   }      
   // GO LONG
   if (OrdersTotal() ==0)
      {
         Stop = Ask - SL*iATR(Symbol(),0,15,0);
         Stop = NormalizeDouble(Stop,Digits);
         Lots = MaxLoss / (Ask - Stop);
         Lots = Lots / (1 +OrdersTotal());
         Lots = NormalizeDouble(Lots, 1);                     
         if (Lots >0)
            OrderSend(Symbol(),OP_BUY,Lots, Ask,5,Stop,0);
      }      
   }         
   
   if (MaClose(6) < MaOpen(7)) 
   {
   
   //  CLOSE LONGS
   if (OrdersTotal()> 0)
   {
   
      for (i=0; i<OrdersTotal(); i++)
         {
            OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
            if (OrderType() == OP_BUY)
               OrderClose(OrderTicket(),OrderLots(),Bid,5);
         }      
   }      
   // GO SHORT
      if (OrdersTotal() == 0)
      {
         Stop = Bid + SL*iATR(Symbol(),0,15,0);
         Stop = NormalizeDouble(Stop,Digits);
         Lots = MaxLoss / (Stop - Bid);
         Lots = Lots / (1 +OrdersTotal());
         Lots = NormalizeDouble(Lots, 1);                     
         if (Lots >0)
            OrderSend(Symbol(),OP_SELL,Lots, Bid,5,Stop,0);
      }      
   }         
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
Files:
wierdema.ex4  4 kb
[Deleted]  

When you change the periods a bit and add a trailing stop this strategy works pretty well.

Hats off.