Search code examples
mql4metatrader4

why do I get this error although I have an operator in my code?


In MQL4, I have the following line

int OP_TYPE = int(0.5((1+f)*OP_BUY+(1-f)*OP_SELL));

which gives the error: '+' - some operator expected.

What am I supposed to do in this case?


Solution

  • You cannot infer calc types using MQL4, make sure you explicitly type your calculation in full.

    int OP_TYPE = int(0.5*((1+f)*OP_BUY+(1-f)*OP_SELL));