1- I want the EA to open a trade on the next crossover, not on the current one.
What do you mean by the next crossover?
2- I can't get the EA to close the first order and then open another one.
You can't close the order by using OrderClosePrice() (returned value is zero, because the order is still open). You have to use Ask or Bid.
Here's the coding:
Why do you use this? The variable "Pips" isn't use in your code! You can delete the whole block.
//====Conversion de 4 a 5 digitos====// double Pips = Point; if(Digitos == Cinco) { Pips = Point*10; } else if(Digitos == Cuatro) { Pips = Point; }
Similar problem. Result of this block is TradeLots is equal to Lots. You should use just Lots. You can delete the whole block.
//====Lotaje o Cerrar en entrada opuesta====// double TradeLots = Lots; if(Lots > 0) { TradeLots = Lots; } else if(Lots == 0) { TradeLots = 0; }
You shouldn't use this coding
if(res == false) ... else if(res == true)
You should use this instead of
if(!res) ... else ...
What do you mean by the next crossover?
You can't close the order by using OrderClosePrice() (returned value is zero, because the order is still open). You have to use Ask or Bid.
Sorry, I'm not too good at english, for example, let's say signal MA is over Slow and Fast one, when I attach the EA it immediately opens the trade even though the crossover was some bars ago.
Because you don't check crossover but just the position of SignalMA. If you want to check crossover you should compare the previous position with the current position.
Why do you use this? The variable "Pips" isn't use in your code! You can delete the whole block.
Similar problem. Result of this block is TradeLots is equal to Lots. You should use just Lots. You can delete the whole block.
You shouldn't use this coding
You should use this instead of
Can you explain me that?
OrderClosePrice() returns close price. If you close the order for example at 1.23000 the OrderClosePrice() will return 1.23000. If the order is still open the OrderClosePrice() returns 0.0 . Similar to OrderCloseTime()
EDIT: see the post #2
I've edited your code but not tested:
Pips variable it's for 4 to 5 broker digits conversion.
OK, but you never use "Pips" in your code behind the block.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I just ended up a MQL4 course and started to mess around with Meta Editor, just a simple MA crossover EA, but I'm having a few problems:
1- I want the EA to open a trade on the next crossover, not on the current one.
2- I can't get the EA to close the first order and then open another one.
The course was damn basic, I think the issue is related to the void Something() stuff, because it was not seen on the code we made, we only use OnTick function, and the system was oriented to work only on a certain hour, so I think I'm trying to code a different kind of system using the wrong logic.
Here's the coding: