Please Help w/ EA Command

Hello Fellow Traders;
I am writing an EA and basically have it done…but I am having issues getting the exit command correct.

I am using multiple indicators to open the position.
To be exact the follow indicators must agree for a buy or sell;
Short Ema vs Long Ema, RSI, MACD w/ Signal, and PSAR.

I would like the exit to happen when any of those above signals disagree.
so in basic terms it would read:
Close “Buy” position if:
SARCurrent>Bid OR Rsi<50 OR MacdCurrent<0 OR SignalCurrent<0 OR ShortEma<LongEma

Problem is that as far as i can tell MQL4 doesnt accept the “OR” command…would I substitute it with the “else” command…I have the rest of the code figured out and this is the last peice of the puzzle before I can test.

Could anybody assist with this command ?
Thank you.

Hi
just going by your code, using the word OR is represented with double pipes || (that’s what I call them) so therefore your code would look like:

SARCurrent>Bid || Rsi<50 || MacdCurrent<0 || SignalCurrent<0 || ShortEma<LongEma

Hope that helps :slight_smile:

thank you
thank you
thank you

:slight_smile:

That’s what i want to know. :slight_smile:


Kind Regards!
William.

Ohhh the Joys of writing an EA LOL.

Ok, another Riddle…at least it is to me.
Is there a way I can attatch an EA to a 15 min Chart, but have it pull information from a 4H indicator…for example, if I were using a Simple Crossover Method on a 15 min chart, but I only want the cross to place a buy order if the 4H char agrees that it is an upward market…it would look something like this…
15 Min Ema:
15_short_ema=iMA(NULL,0,5,0,1,0,0);
15_long_ema=iMA(NULL,0,10,0,1,0,0);
4 Hour Ema:
int i4h
i4h=iBarShift(NULL,PERIOD_H4,iTime(NULL,0,i),true)+1;
4H_short_ema=iMA(NULL,PERIOD_H4,5,0,MODE_EMA,PRICE_CLOSE,i4h);
4H_long_ema=iMA(NULL,PERIOD_H4,10,0,MODE_EMA,PRICE_CLOSE,i4h);

if (15_short_ema > 15_long_ema && 4H_short_ema > 4h_long_ema)
open buy order.

would anyone be able to tell what I am doing wrong with this, or possibily offer a solution to using indicators from a different time frame? I am working with alot more indicators that EMA, but w/ a basic idea I could probally make it work.

Thank you for any time and suggestions.