macd filter

 

I want to filter orders on an ea with whether macd is up or down. I have tried the below. How do I fix it?



double Macdcurrent;


Macdcurrent=iMACD(NULL,0,12,50,9,PRICE_CLOSE,MODE_MAIN,0);



if (Macdcurrent<0){
if (!ExistPositions()){//2
if (PS){//3

OpenSell();
return(0);
}//2
}


Thanks for any help!

Reason: