Really simple coding problem?

 

Hello


would anyone care to advise me why this piece of code doesnt work?



 double MA=iMA(NULL,0,1,0,MODE_SMA,PRICE_CLOSE,0);

 double ST=iCustom(Symbol(),0,"SuperTrend",10,3,0);


   if (MA<ST)

     {                                          

      ObjectCreate("Arrow", OBJ_ARROW,0,1,1);

      Alert("Arrow created?");

     }

   

Im trying to detect if the Super trend indicator is above or below the 1 period MA, but I am not getting an arrow drawn or an alert created.   


Im just getting started with MQL4, so any help would be greatly appreciated



Thanks



 

Hi

Check for errors in jornal, print out MA & ST just before test and check all parameters are present and correct for indicator calls especially iCustom. It is good practice to check returned value of functions like ObjectCreate. I'm not sure what happens if you leave off parameters in a function call. C would complain but MT4 just carries on and doesn't tell you so be vigilant.

 

Seems you're missing a parameter in the SuperTrend call. Try this:

double ST=iCustom(Symbol(),0,"SuperTrend",10,3,0,0);

 
Baluda:

Seems you're missing a parameter in the SuperTrend call. Try this:

double ST=iCustom(Symbol(),0,"SuperTrend",10,3,0,0);

Thanks that appears to be working, except the arrow still wont show....

 

To be on the safe side:

ObjectCreate("Arrow", OBJ_ARROW, 0, Time[0], Ask);
ObjectSet("Arrow", OBJPROP_ARROWCODE, 140);
ObjectSet("Arrow", OBJPROP_COLOR, Yellow);

Your parameters create an arrow at date == 1 and price == 1.

Reason: