Help with MA & MACD coding.

 

Hi All (especially respectful Mladen or MrTool),

I am thinking of trading with a setup like this,

Buy: When price close above 5SMA HIGH and MACD showing positive value (trending up)

Sell: When price close below 5 SMA LOW and MACD showing negative value (trending down)

However, i am not a coder at all and i can basically understand bits of coding language. I have tried to code the SMA already but i think it's wrong because the EA doesn't perform as i wanted to. Please see,

double diClose0=iClose(NULL,5,0);

double diMA1=iMA(NULL,5,7,0,MODE_SMA,PRICE_HIGH,0);

double diClose2=iClose(NULL,5,0);

double diMA3=iMA(NULL,5,6,0,MODE_SMA,PRICE_LOW,0);

------------------------------------------------------------------------------------------

if (!ExistPositions()){

if ((diClose0>diMA1)){

OpenBuy();

return(0);

}

if ((diClose2<diMA3)){

OpenSell();

return(0);

is this the right coding for the SMA function? OH yes, i need help with the MACD function as well but i can't find to code buy when value is positive/ sell when value is negative.

PLease give me a hand.

Jack

 

Hi,

Which settings do you use for MACD?

Can you explain this: MACD showing positive value (trending up) is it when Signal pointing UP? or when signal above Main?

here you can make your indi with an online tool:

Forex Signal Builder Wizard.

for price value use 1Period MA

Reason: