Negative-Positive MACD value check

To add comments, please log in or register
Sajjad Hossain Sagor
17
Sajjad Hossain Sagor  
I need to check if MACD value is negative or positive... 
iMACD(NULL, PERIOD_CURRENT, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, i)

how do i do that? what function available or what custom code do you suggest?

Seng Joo Thio
1208
Seng Joo Thio  
Sajjad Hossain Sagor:
I need to check if MACD value is negative or positive... 

how do i do that? what function available or what custom code do you suggest?

Just need 'if' statement (reference):

double dValue = iMACD(NULL, PERIOD_CURRENT, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, i);
if (dValue>0) { /* do something */ }
else if (dValue<0) { /* do other thing */ }
Conditional Operator if-else - Operators - Language Basics - MQL4 Reference
Conditional Operator if-else - Operators - Language Basics - MQL4 Reference
  • docs.mql4.com
If the expression is true, operator1 is executed and control is given to the operator that follows operator2 (operator2 is not executed). If the expression is false, operator2 is executed.
To add comments, please log in or register