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.
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?
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.
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.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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,