Ema Cross! - page 31

 

I've put together some simple code (it has to be simple for me )

Problem is it won't compile. I'm pretty sure its only a simple (that word again!) problem.

This is the basis for the Stopless EA I was thinking about where the trade is with the trend. Trading is controlled purely by price action alone with no outside influences.

Therefore there is no SL, TP or TS!

The idea is for the trade to start one bar after a cross of the ema's (to allow the trade to settle into a trend).

And the trade to finish when the ema's simply cross back again!

Pure and Simple. What shall we call it? "Pure Cross"?

If anyone can check out the compile problem I would be very grateful.

Thanks.

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

//| EMA_CROSS.mq4 |

//| Coders Guru |

//| https://www.mql5.com/en/forum |

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

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

//| Messed about by : demag!! |

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

#property copyright "Coders Guru"

#property link "https://www.forex-tsd.com"

//---- input parameters

extern double Lots = 0.1;

extern int ShortEma = 3;

extern int LongEma = 7;

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

//| expert initialization function |

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

int init()

{

//----

//----

return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

bool isNewSymbol(string current_symbol)

{

//loop through all the opened order and compare the symbols

int total = OrdersTotal();

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

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

Print( "OrderSymbol = " + OrderSymbol() + ": Symbol = " + current_symbol);

string selected_symbol = OrderSymbol();

if (current_symbol == selected_symbol)

return (False);

}

return (True);

}

int Crossed (double line1 , double line2)

{

static int last_direction = 0;

static int current_direction = 0;

//Don't work in the first load, wait for the first cross!

static bool first_time = true;

if(first_time == true)

{

first_time = false;

return (0);

}

if(line1>line2)current_direction = 1; //up

if(line1<line2)current_direction = 2; //down

if(current_direction != last_direction) //Direction changed

{

last_direction = current_direction;

return (last_direction);

}

else

{

return (0); //Direction not changed

}

}

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

//| expert start function |

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

int start()

{

//----

int cnt, ticket, total;

double SEma, LEma;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

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

LEma = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,0);

static int isCrossed = 0;

isCrossed = Crossed (LEma,SEma);

total = OrdersTotal();

if(total < 1 || isNewSymbol(Symbol()))

{

if(isCrossed == 1 )

{

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(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);

}

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

{

// should it be closed?

if(iMA(NULL,0,3,PRICE_CLOSE,0)>7)

{

OrderCloseBy(order_id,opposite_id);

return(0);

}

return(0);

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

 

Thankyou for that update Codersguru, I'll let this baby run for a week & post results, on 5min, & 15min untouched. the same as before except with a bit of good old human interaction. keep you posted with the results. This EA will only trade EU/US trade sessions only.

Jorgka

 

Codersguru why some time I down load the ea in different time and difference version have difference resauld ? is there some khind of bug or some thing khinda bugging the ea code ? I down load the latest one again and it work look like find .in wht sercumsentence do you change counter and follow the trand ?and in what situation you close your ea trade manualy shouldent it close by it self? and I come a cross were the ea on some pair close but it do the corection and open again . supose it close and open anew poss and close again or wht ? cheers

 

Req.EA for my system

Hi everybody,

If anybody could make it easy

I always trade manually with my set up indicator over 2 years, generally they are crossing EMA too, but with any condition.

Here is my set up Indicator.

EMA : 5 , 18 (All in close)

RSI : 8

Slow Stoch : 15 , 5 , 5

Entry Market ( Buy/Sell) when both EMA are crossing with conditon

- Buy if RSI > 50 , Slow Sochastic >40 in Time Frame 15 mnt n 1 Hour

- Sell If RSI < 50 , Slow Stoch < 60

- Stop Loss 35 pips (at above or below EMA crossing point in TF 15 mnt)

- Target Profit 120 pips

- Traling Stop 30 pips

- order 1 lot

I will appreciate for him/her to make it,

Thanks in advanced

God Bless U

4xtrader

 
4xtrader:
Hi everybody,

If anybody could make it easy

I always trade manually with my set up indicator over 2 years, generally they are crossing EMA too, but with any condition.

Here is my set up Indicator.

EMA : 5 , 18 (All in close)

RSI : 8

Slow Stoch : 15 , 5 , 5

Entry Market ( Buy/Sell) when both EMA are crossing with conditon

- Buy if RSI > 50 , Slow Sochastic >40 in Time Frame 15 mnt n 1 Hour

- Sell If RSI < 50 , Slow Stoch < 60

- Stop Loss 35 pips (at above or below EMA crossing point in TF 15 mnt)

- Target Profit 120 pips

- Traling Stop 30 pips

- order 1 lot

I will appreciate for him/her to make it,

Thanks in advanced

God Bless U

4xtrader

Do you have sucess with this system, trading manually? Could you post some reports please?

 

???

Hendrick, Codersguru i'm testing the Ea since yesterday, default settings, except lote size, and take profit (30 pips), but is not looking good man

Files:
sem_ttulo_2.gif  43 kb
 
4xtrader:
Hi everybody,

If anybody could make it easy

I always trade manually with my set up indicator over 2 years, generally they are crossing EMA too, but with any condition.

Here is my set up Indicator.

EMA : 5 , 18 (All in close)

RSI : 8

Slow Stoch : 15 , 5 , 5

Entry Market ( Buy/Sell) when both EMA are crossing with conditon

- Buy if RSI > 50 , Slow Sochastic >40 in Time Frame 15 mnt n 1 Hour

- Sell If RSI < 50 , Slow Stoch < 60

- Stop Loss 35 pips (at above or below EMA crossing point in TF 15 mnt)

- Target Profit 120 pips

- Traling Stop 30 pips

- order 1 lot

I will appreciate for him/her to make it,

Thanks in advanced

God Bless U

4xtrader

Hi 4xtrader,

Which pairs do you trade?

 

USD struggles!

creative:
Hendrick, Codersguru i'm testing the Ea since yesterday, default settings, except lote size, and take profit (30 pips), but is not looking good man

creative,

I think yesterday was very hard day! I think some news has affected the USD (maybe the bomb of Pakistan)

Just wait and everything well be OK!

This is my statement still a winner!

 

Your statement it's sweet coders . I will wait,and let you know..

Thanks!

 
codersguru:
creative,

I think yesterday was very hard day! I think some news has affected the USD (maybe the bomb of Pakistan)

Just wait and everything well be OK!

This is my statement still a winner!

hi, codesguru and everbody

i had lost hope in forex until this EA.

I demo-ed it on usd/cdn , usd/jpy , eur/jpy , usd/chf , gbp/usd on thursday night and the next morning was non farm news. I wanted to see if it survives.

And it did , all winners.

thank you and i will keep trying it out and will forward the results.

Reason: