# how to sell at two lines ema 7 as ema 21 overlap at that time

35

how to sell at two lines ema 7 as ema 21 overlap at that time

Who can help me

Thanks

1028

Right click -> Trading -> New order
35

tonny:
Right click -> Trading -> New order
oh .... no. i want code a ea auto sell
15062

You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
35

WHRoeder:
You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.

thank you

i write code but it does not work

double pBid = MarketInfo(OrderSymbol(), MODE_BID);
double ma7 = pBid - iMA("EURJPYpro",PERIOD_M30,7,0,MODE_EMA,PRICE_CLOSE,1);
double ma21 = pBid - iMA("EURJPYpro",PERIOD_M30,21,0,MODE_EMA,PRICE_CLOSE,1);

if ( ma7  ==  ma21 )
{  BUY("EURJPYpro",LS,TP,SL,TS,"if ( ma7  ==  ma21)") ;}

code

if   ( iMA("EURJPYpro",PERIOD_M30,7,0,MODE_EMA,PRICE_CLOSE,0)  >  iMA("EURJPYpro",PERIOD_M30,21,0,MODE_EMA,PRICE_CLOSE,0) )

it do work

can you help me Search error

thanks

15062

axbc: i write code but it does not work

if ( ma7  ==  ma21 )
1. Of course not because they cross, they are (almost) never equal. The == operand. - MQL4 forum
2. So check for a cross not levels
double ma07cur = iMA(NULL,0, 7,0,MODE_EMA,PRICE_CLOSE,1),
ma21cur = iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE,1),
ma07pre = iMA(NULL,0, 7,0,MODE_EMA,PRICE_CLOSE,2),
ma21pre = iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE,2);
bool wasAbove = ma07pre > ma21pre,
isAbove = ma07cur > ma21cur;
if(isAbove != wasAbove) // Crossed.

3. "EURJPYpro",PERIOD_M30
Don't hard code symbols and periods when unnecessary. You want you EA to be able to work on other pairs and timeframes, don't you?
4. double pBid = MarketInfo(OrderSymbol(), MODE_BID);
Don't use function calls when you can use predefined variable Bid
35

WHRoeder:
1. Of course not because they cross, they are (almost) never equal. The == operand. - MQL4 forum
2. So check for a cross not levels

oh ... yes. i will try with it.

thank you :)

35

WHRoeder:
1. Of course not because they cross, they are (almost) never equal. The == operand. - MQL4 forum
2. So check for a cross not levels
3. Don't hard code symbols and periods when unnecessary. You want you EA to be able to work on other pairs and timeframes, don't you?
4. Don't use function calls when you can use predefined variable Bid

3. yes

4. I know now.

thank you