Ema Cross! - page 55

 

Ema_cross_2

Dear codersguru,

Thank you for your EA and your countertrend concept,

Even for the first time, me and my friend are skeptical of this countertrend method, but after studying and running forward testing your EA, we've surprised with the results

We still continuing forward test EMA_CROSS_2 with timeframe H1, but we found something interesting in pair EUR/USD 03 April 2006, after crossing down, this EA open sell position instead buy position.... is it normal act? (see attachment)

Thank you...

dedywind

 

7

Hi floks,

I've wrote 10 EAs for the contest, but they were to much to test.

So, I'll select 3 of them to the contest and submit the 7 here They are making profit in forward tests.

Hope you enjoy!

 

Coders,

I will go back and read the complete thread, but I cannot remember if this was addressed.

When you close out the Platform, whether it be InterbanFX, MT4, ects., I noticed that if I am not in a position, and I have the latest MA EA on it will auto execute a trade.

How do we keep this from happening everytime we reopen the software.

thanks

 

Newbie needs help with MA cross EA...

codersguru:
amarnath,

This is my report (attached)!

And this is the version I used (attached)!

I think we can't relay only on the backtest. But My in my test I used the date from 2005/01/01 to Today!

Anybody forward test the MoneyMaker?

Hi CodersGuru,

I modified your original EMA_Cross EA a bit to work with a 5 EMA and a 10 LWMA cross with an RSI and Stochastic filter. While this EA opens LONG and SHORT orders and closes out of them correctly, it does not allow me to simultaneously CLOSE a position and then immediately OPEN a new position in the opposite direction (e.g.: true "swing" trading technique). Thus, I lose out on a great deal of potential swing trades.

In addition, sometimes the cross conditions of EMA1 > WMA1 and EMA2 < WMA2 may not trigger a buy if the two moving averages for the past period were the same value or within 1 to 2 pips of each other. Thus I would like to add in the code to look for that kind of condition (which often happens) to trigger an entry.

I am not a coder, so I was hoping you could help me figure out how to do this.

I've included my code inline below as well as the MQ4 file as an attachment. Any help would be very, very appreciated!

//+----------------------------------------------------------------------------------------+

//| 5/10 MA Cross w RSI and Stoch Filter |

//| Ian Boersma - Copyright 2006 |

//| |

//+----------------------------------------------------------------------------------------+

#property copyright "Ian Boersma"

//---- input parameters

extern double TakeProfit=100;

extern double Lots=1;

extern double TrailingStop=35;

extern int ShortEma = 5;

extern int LongWma = 10;

extern int RSIPer = 14;

extern int StochK = 10;

extern int StochD = 3;

extern int StochSlow = 3;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function +

//| This is where we initialize internal variables for program use + |

//+------------------------------------------------------------------+

int start()

{

//----

//LotCalc Declarations

int cnt, ticket, total;

//MAs and Filter Variable Declarations

double RSI;

double Stoch;

double EMA1,EMA2,WMA1,WMA2;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

//MA and Filter Variable Definition

EMA1 = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,0);

WMA1 = iMA(NULL,0,LongWma,0,MODE_LWMA,PRICE_CLOSE,0);

EMA2 = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);

WMA2 = iMA(NULL,0,LongWma,0,MODE_LWMA,PRICE_CLOSE,1);

RSI = iRSI(NULL,0,RSIPer,PRICE_CLOSE,0);

Stoch = iStochastic(NULL,0,StochK,StochD,StochSlow,MODE_SMA,0,MODE_MAIN,0);

int isCrossed = 0;

if (EMA1 > WMA1 && EMA2 = 50 && Stoch < 80)

{isCrossed = 1;

}

if (EMA1 = WMA2 && RSI 20)

{isCrossed = 2;

}

//We check the trading terminal to see if it is empty

total = OrdersTotal();

if(total < 1) //If trading terminal is empty...

{

if(isCrossed == 1) //if cross indicates LONG swing...

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,2,0,Ask+TakeProfit*Point,"My EA",12345,0,Yellow);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

if(isCrossed == 2) //if cross indicates SHORT swing...

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,2,0,Bid-TakeProfit*Point,"My EA",12345,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

}

return(0);

}

//Position exit function...

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

OrderPrint();

if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())

{

if(OrderType()==OP_BUY) // long position is opened

{

// Check if we have a SHORT cross condition...

if(isCrossed == 2)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

return(0); // exit

}

// Check our trailing stop to see if it needs to be adjusted

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

else // go to short position

{

// Check if we have a LONG cross condition...

if(isCrossed == 1)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position

return(0); // exit

}

// Check our trailing stop to see if it needs to be adjuste

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

return(0);

}

//+------------------------------------------------------------------+

 
iboersma:
Hi CodersGuru,

I modified your original EMA_Cross EA a bit to work with a 5 EMA and a 10 LWMA cross with an RSI and Stochastic filter. While this EA opens LONG and SHORT orders and closes out of them correctly, it does not allow me to simultaneously CLOSE a position and then immediately OPEN a new position in the opposite direction (e.g.: true "swing" trading technique). Thus, I lose out on a great deal of potential swing trades.

In addition, sometimes the cross conditions of EMA1 > WMA1 and EMA2 < WMA2 may not trigger a buy if the two moving averages for the past period were the same value or within 1 to 2 pips of each other. Thus I would like to add in the code to look for that kind of condition (which often happens) to trigger an entry.

I am not a coder, so I was hoping you could help me figure out how to do this. ....

I'll check it !

 
codersguru:
I'll check it !

Thanks for your help...

- Ian

 
codersguru:
I'll check it !

CodersGuru,

I've attached a newer version of my EA as I spotted an issue with determining the 'isCrossed' condition (I tried to add the RSI and Stoch filters to the original isCrossed condition rather than adding it as a qualifier only for entering a position.

Hopefully this makes more sense...

- Ian

 
iboersma:
Thanks for your help... - Ian

I think point 1 is working (when close buy open sell and when close sell open buy) Look at the attched test.

Files:
 
codersguru:
I think point 1 is working (when close buy open sell and when close sell open buy) Look at the attched test.

Cool. That definitely looks like the stope and reverse type system I'm looking for (though the net profit doesn't look very encouraging...:))

I've been using this system manually for a week or so and have had some very encouraging results, so it will be interesting to get the full backtesting numbers back to see if I'm onto something or am just lucky...

- Ian

 
gody6000:
this is 2nd week lol http://9q9q.com/March/1144348631.zip

Sorry! but what is this?

Reason: