Close all orders when one order is close & Open order on the same price the first order was open..

To add comments, please log in or register
Rod Barias
159
Rod Barias  

hello guys. can anyone help me with this. im trying to add a code that  will 1.) close all order when one order is close.  2.) open order on the price the first order was open.

Ubzen
5298
Ubzen  

To close all orders, you'll have to cycle through all orders and close the ticket#. If order close succeed, you'll get a true value otherwise you'll get an error message. You'll want to save the OrderOpenPrice() of the first order prior to closing || you'll want to loop through history and get the OrderOpenPrice(). When OrdersTotal()==0 || CustomOrderTotal()==0 then place the new order.

De-bugging your code takes hours and thats how you'll learn, sorry, I have hours of my own codes to de-bug.

For example on CloseAllOrders: https://www.mql5.com/en/code/7607.

For de-bugging tips look here: What are Function Return.

Rod Barias
159
Rod Barias  
ubzen:

To close all orders, you'll have to cycle through all orders and close the ticket#. If order close succeed, you'll get a true value otherwise you'll get an error message. You'll want to save the OrderOpenPrice() of the first order prior to closing || you'll want to loop through history and get the OrderOpenPrice(). When OrdersTotal()==0 || CustomOrderTotal()==0 then place the new order.

De-bugging your code takes hours and thats how you'll learn, sorry, I have hours of my own codes to de-bug.

For example on CloseAllOrders: https://www.mql5.com/en/code/7607.

For de-bugging tips look here: What are Function Return.


 thanks ubzen, i will try this looping precess..
whroeder1
17946
whroeder1  
05121981: im trying to add a code that  will 1.) close all order when one order is close.  2.) open order on the price the first order was open.
  1. Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.
  2. You can't open at any price you want, you can only open at the current market price. You can use a buy/sell-limit/stop to set a price and the broker will open the order if market reaches it. This is normally used for manual trading as the EA can watch each tick and open when market reaches the trigger price.
To add comments, please log in or register