Execute function if variable x is more than variable y
if(x>y) { //Execute Buy order } else if(x<y) { //Execute Sell order }
.
pluck6:
but how do I establish the variables? Would it be something like this:
var x = 1;
var y = 3;
That wouldn't make sense. There would have to be some conditions that would assign a value to the variables.
Finally, should I wrap this whole code within void OnStart() {} ?
pluck6: I'm struggling to find the MQL4 code which establishes variables which can then be compared against each other e.g. x > y and vice versa, so any help would be greatly appreciated.
- Before programing in MQL4, I suggest you first familiarise yourself with code in general such as in a language called "C".
- After that, read through the "MQL4 Book/Tutorial" section on this site, which will introduce you to all the basic things you first need to learn, such as how to declare variables, etc.
- When in doubt, and before posting here, always consult the Documentation, whether that be the Online Version on via the Help (F1) in the Editor/Compiler.
Using MQL4, how can I execute a BUY order (seen below) if one variable x has a value of 1 and another variable y has a value of 3? I need it to work like this:
Variable x = 1
Variable y = 3
So if x is MORE THAN y, execute this script:
And if x is LESS THAN y, execute this SELL script:
I'm struggling to find the MQL4 code which establishes variables which can then be compared against each other e.g. x > y and vice versa, so any help would be greatly appreciated.