MACD Script Returns Zero

 

Hello,

I am testing a script, and I'm getting inconsistent results that I do not understand. I have the NZDUSD chart open when testing this script.

When I code the following and Print "a", I receive a valid numeric value:

double a = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,1);

When I code the following and Print "a", I receive a zero:

double a = iMACD("NZDUSD",1440,12,26,9,PRICE_CLOSE,MODE_MAIN,1);

Thanks for any help. It is appreciated.

 
See 'Question on access to other timeframe' - similar duscussion. Make sure that your daily chart previously opened
 
stringo:
See 'Question on access to other timeframe' - similar duscussion. Make sure that your daily chart previously opened


Stringo,

Thanks for the quick reply.

I do have the daily chart opened for NZDUSD. I guess that's what I'd like to understand. Why does the script work with NULL as the currency, which I understand defaults to the current chart, and when I explicitly specify the symbol as a string, as "NZDUSD", it returns a zero.

The goal of this script is to check values in all opened charts, and display an alert if my criteria is met. Obviously the zero value is a big obstacle in my strategy.

Any ideas or suggestions?

Thanks

 
What return such
Print("The current Symbol mane is ",Symbol());
on NZDUSD chart ?
 
Rosh:
What return such
Print("The current Symbol mane is ",Symbol());
on NZDUSD chart ?


Hey Rosh,

I executed your script, and the output from the print statement really surprised me. It reported the current Symbol name as NZDUSDm. I have no idea what the "m" is. All of the help I've seen in the forums specifically state using the currency name in quotes, and nowhere did they reference "m".

In any event, I modified my code to append the "m" to the currency names, and it is working as designed.

Thank you for sharing your knowledge with me, and any future people that may run into this issue. Perhaps the documentation for the inicators can be updated to state something to the effect: NULL defaults to the current currency on the opened chart, and you need to specify a suffix of "m" to the currency name in place of NULL if you want to access a different currency. That would have saved me many hours of code debugging.

Thanks again!

:)

 
arb56:
Rosh:
What return such
Print("The current Symbol mane is ",Symbol());
on NZDUSD chart ?


Perhaps the documentation for the inicators can be updated to state something to the effect: NULL defaults to the current currency on the opened chart, and you need to specify a suffix of "m" to the currency name in place of NULL if you want to access a different currency.

No. the documentation is correct in this case. It's better to always follow Rosh's suggestion to check what the actual symbol name by printing its value. So the lesson learn here is to check its value, not to assume anything.

I think the suffix "m" is an incorrect setup at the broker's server.
Reason: