MACD Signal line returning a false value

 

Hi all, I just came across this problem in coding an EA and need know help/pointers as to how to go about it.

Need know when MACD "Signal Line" returns a negative or positive value so i tried the following:

if (macdSignal > 0) macdTrend = "Up";

if (macdSignal < 0) macdTrend = "Down";

if (macdSignal == 0) macdTrend = "Flat";

The above works fine on every currency pair except JPY pairs and some commodities. According to observation, it may have something to do with the returned value digits, cos i have seen when it's 4digits (0.0000) on any currency pair or commodity, it works just fine yielding expected results but anything less, say 3digits(0.000) which is TRUE for all JPY pairs and most commodities, i get nothing(no signal).

I am hoping someone out here knows the fastest route through this, easy and non complex (hehehe yeah i believe the best solutions are always the easy once regardless of how complex they may seem most times), yielding accurate data analysis. Thanks

 
How do you assign a value to macdSignal?
 
GumRai:
How do you assign a value to macdSignal?

double macdSignal = iMACD(NULL,timeFrame,macdFastSMA,macdSlowSMA,macdSMA,price,MODE_SIGNAL,shift);
 

I cannot think of any reason why Digits should affect this.

I can only suggest that you put some Print statements in your code to see if macdSignal is returning what you expect. That may help you to pinpoint the problem.

 

Yeah, i thought so too, leading to an error at my stead and didn't last long(say of me a novice). The problem was in declaration of ''price" i used: price = iOpen(symbol,timeFrame); instead of: PRICE_OPEN in the MACD declaration : iMACD(NULL,timeFrame,macdFastSMA,macdSlowSMA,macdSMA,price,MODE_SIGNAL,shift);

Though still not sure as to why this didn't work for MACDSIGNAL value < 4digiits, but worked for MACDSIGNAL value > 4digits . However a found solution, i would still love to know the WHY?

 
omovaze:

Yeah, i thought so too, leading to an error at my stead and didn't last long(say of me a novice). The problem was in declaration of ''price" i used: price = iOpen(symbol,timeFrame); instead of: PRICE_OPEN in the MACD declaration : iMACD(NULL,timeFrame,macdFastSMA,macdSlowSMA,macdSMA,price,MODE_SIGNAL,shift);

Though still not sure as to why this didn't work for MACDSIGNAL value < 4digiits, but worked for MACDSIGNAL value > 4digits . However a found solution, i would still love to know the WHY?


Possibly because most 4 digit + instruments' price when read as an integer will return a value of 6 or less, so within the range for applied price constants.

Price of Japanese pairs and commodities will return an integer much higher than 6

 
GumRai:


Possibly because most 4 digit + instruments' price when read as an integer will return a value of 6 or less, so within the range for applied price constants.

Price of Japanese pairs and commodities will return an integer much higher than 6


Thanks
Reason: