EA coding help!

I am try to write a EA help me to check Candle sticks, but i don’t know how to coding it, somebody who expert MQL4, please ! help me .

  • I have a [B]Candle sticks[/B] on time frame [B]M1 [/B].

  • One [B]Bollinger bands[/B] with[B] Period is 18[/B].

  • One [B]Moving Average (3, exponential, close)[/B].

  • One [B]MACD Histogram[/B].

  • One [B]RSI [/B]with [B]period is 14[/B].

Now i want to check when[B] EMA 3 cut down Middle Bollinger bands[/B] and [B]RSI 14 over 50%[/B] and [B]MACD Histogram over 0[/B] the code return to me [B]BUY[/B]. IF [B]EMA 3 cut down Middle Bollinger bands[/B] and [B]RSI 14 below 50%[/B] and [B]MACD Histogram below 0[/B] the code return to me [B]SELL[/B].

If somebody have not time, just help me how to check the [B]EMA cut down Middle Bollinger bands[/B] . That’s all.

I really need somebody help.Thank you very much !

What do you mean by "EMA cut down the middle Bollinger Bands?

Post up a screen shot of the chart. It would be easier to describe.

Also, think about your code logic. If the “true” is all you’re really looking for, anything else would be false right?

So why bother looking for a false, and having the extra code lines? Why not just return the “true” only, and let the rest just be ignored?

I mean the Red line Moving Average cut down the Middle line Bollinger bands on the image below.Thanks !

If you are using the middle part of the Boll, you are just using an EMA. Do you use the outside bands in any fashion?

Pick any “Moving Average Cross EA”, and add your RSI and MACD code, and you’re done.

This is the code what i done, but it’s not run, and i am sure i can not check Cut Down, somebody please help :

[B]int Order = SIGNAL_NONE;

double iBB = iBands(NULL,0,18,2,0,PRICE_CLOSE,MODE_SIGNAL,0);
double EMA = iMA(NULL,0,3,1,MODE_EMA,PRICE_CLOSE,0);
double MACD = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
double RSI = iRSI(NULL,0,14,PRICE_CLOSE,0);

if(iBB==EMA && RSI > 50 && MACD > 0 ) Order = SIGNAL_BUY;
if(iBB==EMA && RSI < 50 && MACD < 0 ) Order = SIGNAL_SELL;
//==================================================================

if (Order == SIGNAL_BUY){

  Print("I am ready to BUY");

}

if (Order == SIGNAL_SELL){

  Print("I am ready to SELL");   

}[/B]

You are setting up impossible conditions.

Your very first condition is (iBB==EMA). Since the two moving averages are quite different in period, there will rarely if EVER be a time in which that condition is true. You should be using >=, or <=. That way the EMA can be higher, or lower than iBB, and finally pass on through the code.

You should also set those up as “if” statements, instead of your all in one setup there. For instance you have:

//–
if(iBB==EMA && RSI > 50 && MACD > 0 ) Order = SIGNAL_BUY;
//–

That means that your code will run on every tick using processor power.

If you use nested “if” statements, like this:


//--
if (iBB == EMA){
  if (RSI > 50){
    if (MACD > 0){
    }
  }
}
//--

That way it cycles through only the first set of conditions rather than all of them. If the first set is not true, it looks no more. It makes your program a bit faster, and saves processor power.

You might also want to get some variables involved in the other parts of your code.

I’ve not had consistent success using numbers in the conditions involving RSIs, or MACDs.

Instead of:

if (RSI > 50)

Maybe use:

extern int rsi_value = 50;

if (RSI > rsi_value)

The hardest debugging I’ve had to deal with, is often finding issues that arise when I am actually returning a value, but that value wasn’t the intended result. So these days I comment on screen to see what I am returning. It helps me troubleshoot my logic a lot faster.

Cheers!

I am new into EA and looking for a EA coder to help me out and teach me also.From this discussion it seems EA is not that easy but will see.