what order u want 2 close u should loop Through all orders to do that
what order u want 2 close u should loop Through all orders to do that
I just want everything in my account to be closed (max 2 open orders) but I can't find a way to set a variable to my OrderTicket() slot
example I have a USD/JPY Sell with no stop loss no take profits and a Sell GBP/JPY with about same settings
OrderSend("GBPJPY", OP_BUY, 1, Bid, 0, 0, 0, "", 0, 0);
OrderSend("USDJPY", OP_SELL, 1, Bid, 0, 0, 0, "", 0, 0);
how do I figure out the OrderTicket() to put on my value and what are the commands to set up values also
for example values named
order1 and order2
I want the script to be able to figure when to close them both at the time.
would be something like
OrderClose(order1, 1, Bid, 0, 0);
OrderClose(order2, 1, Bid, 0, 0);
I want what's coming up top of it
also I know that I don't take 2x buy or 2x sell maybe this could be easyer to program each differant order to a value.
to make it short I only need to be able to grab the order_id from somewhere either when I take orders or when I am about to close them I just want the most simple way to get it.
u can do like this:
int ticket1 = OrderSend(.....); int ticket2 = OrderSend(.....); //& then when u want to close OrderClose(ticket1,....); OrderClose(ticket2,....);
or
for(int cnt = OrdersTotal(); cnt >= 0; cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); //---- if(OrderSymbol() == Symbol()) //or any condition u like OrderMagicNumber() etc. { if(OrderType() == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Blue ); } if(OrderType() == OP_SELL) { OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Red); } } }
u can do like this:
or
Hi, I'm very glad you awnser my post :) you are very helpful to me but I only have a small question about this one
int ticket1 = OrderSend(.....); int ticket2 = OrderSend(.....); //& then when u want to close OrderClose(ticket1,....); OrderClose(ticket2,....);
would it be that way?
OrderClose(ticket1, 1, Bid, 0, 0);
OrderClose(ticket2, 1, Bid, 0, 0);
Sleep(15000);
OrderSend("GBPJPY", OP_BUY, 1, Bid, 0, 0, 0, "", 0, 0);
OrderSend("USDJPY", OP_SELL, 1, Bid, 0, 0, 0, "", 0, 0);
int ticket1 = OrderSend("GBPJPY", OP_BUY, 1, Bid, 0, 0, 0, "", 0, 0);
int ticket2 = OrderSend("USDJPY", OP_SELL, 1, Bid, 0, 0, 0, "", 0, 0);
or I would have to make it something else.
Ok now I have a problem with my int ticket variables...
when it comes the time to compile it tells me that these variables are already defined and apparently can not be defined once again
I would need them to reset or to find a way to change their value to the next order tickets...
is this possible?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I am working on a script for a few weeks now but can not figure out how to make this feature work.
I am trying to just close all open positions at some point of my script
nothing seem to work but it keeps opening positions so how could it be possible to just close everything
here is my base code for this part of my script
OrderClose(OrderTicket(), OrderLots(), Bid, 0, 0);
OrderClose(OrderTicket(), OrderLots(), Bid, 0, 0);
can I replace OrderTicket() with something universal that would close the first thing or I would need to gather it from somewhere?
if so how do I make it grab this value?