Download MetaTrader 5

EA Question - Close the order if reversal or the same signal occured

To add comments, please log in or register
We have launched Spanish and Portuguese versions of the website. Try them!
assemosman85
12
assemosman85 2015.04.15 14:13 

Hello,

I have a buying criteria and a selling criteria

What I want is to close a buy order if:

1) Selling criteria occurred (Reversal)

or

2) If another Buy signal occurred after opening the first one. I want to close the first buy order and enter a new buy order.


And vice versa for the sell order.


When I put the same buy or sell criteria for closing the order in the script, Metatrader enters and close the order at the same price several times, all I want to do is to tell it to wait one bar after opening the position and check, and I don't know how to do that.

I really appreciate your help in this.

Thank you,

Miguel
30
Miguel 2015.04.15 21:08  

Try to put the code that closes the orders before the code that opens them. I assume that you check if there is a new bar before checking to open an order.

 Regards. 

Keith Watford
Moderator
9624
Keith Watford 2015.04.15 22:45  
assemosman:


2) If another Buy signal occurred after opening the first one. I want to close the first buy order and enter a new buy order.

Why gift the broker the spread everytime, when you can simply keep the trade open?
assemosman85
12
assemosman85 2015.04.17 17:41  
GumRai:
Why gift the broker the spread everytime, when you can simply keep the trade open?

Sometimes when I open a buy order and the price goes down but doesn't reach the stop loss, and then back up again with a new buy entry with a different take profit that maybe like -2 points for the first entry.

The other solution is to modify the stoploss and take profit of the first order if a specific criteria occurs, which I don't know how to do also.

assemosman85
12
assemosman85 2015.04.17 17:42  
xiruko:

Try to put the code that closes the orders before the code that opens them. I assume that you check if there is a new bar before checking to open an order.

 Regards. 

Thank you Xiruko, I will try that.
To add comments, please log in or register