```
if(isNewBar //Send order when new bar opens
&& Cross(4, iMA(NULL, PERIOD_CURRENT, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, 1) > iMA(NULL, PERIOD_CURRENT, FastEMA, 0, MODE_EMA, PRICE_CLOSE, 1)) //Moving Average crosses above Moving Average
&& iRSI(NULL, PERIOD_CURRENT, RSI, PRICE_CLOSE, 1) >= 50 //Relative Strength Index >= fixed value
&& iMFI(NULL, PERIOD_CURRENT, MFI, 1) >= 50 //Money Flow Index >= fixed value
&& iMomentum(NULL, PERIOD_CURRENT, Momentum, PRICE_CLOSE, 1) >= 50 //Momentum >= fixed value
&& iMACD(NULL, PERIOD_CURRENT, MACD_Fast, MACD_Slow, MACD_SMA, PRICE_CLOSE, MODE_MAIN, 1) >= 0 //MACD >= fixed value
&& iStochastic(NULL, PERIOD_CURRENT, 10, 50, 3, MODE_SMA, 0, MODE_SIGNAL, 1) >= iStochastic(NULL, PERIOD_CURRENT, 10, 50, 3, MODE_SMA, 0, MODE_MAIN, 1) //Stochastic Oscillator >= Stochastic Oscillator
)
```

```
if(isNewBar //Send order when new bar opens
&& Cross(5, iMA(NULL, PERIOD_CURRENT, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, 1) < iMA(NULL, PERIOD_CURRENT, FastEMA, 0, MODE_EMA, PRICE_CLOSE, 1)) //Moving Average crosses below Moving Average
&& iRSI(NULL, PERIOD_CURRENT, RSI, PRICE_CLOSE, 1) <= 50 //Relative Strength Index <= fixed value
&& iMFI(NULL, PERIOD_CURRENT, MFI, 1) <= 50 //Money Flow Index <= fixed value
&& iMomentum(NULL, PERIOD_CURRENT, Momentum, PRICE_CLOSE, 1) <= 50 //Momentum <= fixed value
&& iMACD(NULL, PERIOD_CURRENT, MACD_Fast, MACD_Slow, MACD_SMA, PRICE_CLOSE, MODE_MAIN, 1) <= 0 //MACD <= fixed value
&& iStochastic(NULL, PERIOD_CURRENT, 10, 50, 3, MODE_SMA, 0, MODE_SIGNAL, 1) <= iStochastic(NULL, PERIOD_CURRENT, 10, 50, 3, MODE_SMA, 0, MODE_MAIN, 1) //Stochastic Oscillator <= Stochastic Oscillator
)
```

That might work… but your code seems unnecessarily overcomplicated. Try this Cross function:

```
int Cross(){
10EMA_2=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE,2);
10EMA_1=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE,1);
3EMA_2=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,2);
3EMA_1=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,1);
if(3EMA_2<=10EMA_2 && 3EMA_1>10EMA_1){return(1);}
if(3EMA_2>=10EMA_2 && 3EMA_1<10EMA_1){return(-1);}
return(0);
}
if(Cross()>0 && RSI && Momentum && MACD && ...){OpenBuyOrder...}
if(Cross()<0 && RSI && Momentum && MACD && ...){OpenSellOrder...}
```

And the NewBar function is weird…

```
bool NewBar()
{
static datetime LastTime = 0;
bool ret = Time[0] > LastTime && LastTime > 0;
LastTime = Time[0];
return(ret);
}
Huh?
bool NewBar(){
if(bars!=Bars){//new bar
bars=Bars;//reset bars to current bar value
return(true);
}
else return(false);
}
```