Download MetaTrader 5
To add comments, please log in or register
MQL5 library has more than 1500 apps already. Contribute your own one!
omovaze
37
omovaze 2014.02.06 10:36 

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

Keith Watford
Moderator
8016
Keith Watford 2014.02.06 12:13  
How do you assign a value to macdSignal?
omovaze
37
omovaze 2014.02.06 13:26  
GumRai:
How do you assign a value to macdSignal?

double macdSignal = iMACD(NULL,timeFrame,macdFastSMA,macdSlowSMA,macdSMA,price,MODE_SIGNAL,shift);
Keith Watford
Moderator
8016
Keith Watford 2014.02.06 21:09  

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.

omovaze
37
omovaze 2014.02.07 12:18  

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?

Keith Watford
Moderator
8016
Keith Watford 2014.02.07 12:54  
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

omovaze
37
omovaze 2014.02.09 08:39  
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
/
To add comments, please log in or register