When I compiled a get this error: "if" - expressions are not allowed on a global scope, on lines 42 and 50.
} <<< This terminates OnTick()
//orden de entrada compra <<< Here down are expressions on a global scope
some things to have in mind
1. You should read the MQL reference manual, section "MQL programs"
2. IF statements (and WHILE and similar) , in general all your logic has to be inside a function - be it OnTick(), OnTimer() or your own aFunction();
3. After reading the manual, you will normally realise that OnTick() is running/executed on every single tick that comes from the market. That means also that all the variables you have declared
inside there will be declared each and every time OnTick is running (it can be several times per second). Of course, this is not something you would likely want, so I suggest moving the declarations
outside of all functions (contrary to the program logic, variable and function declarations can happen outside of every function), in company with your extern ones, like
and then put inside OnTick() only the part
PreviousSloMA = iMA (NULL, 0, SlowMA, 0,MODE_EMA,PRICE_CLOSE, 2);
To add comments, please log in or register