when you run the script, it directly read your open order on MT4 and write to “openorders.txt” at “…\MQL4\Files\TradeFromCsvFile" so you can read all info your open order. But this script working with order comment.
there is comment number for every order so you have to use comment number when you want to close or modify your open order.
If you want open 3 lots on EURUSD pair,
Amibroker write to “commandfile.txt” like //OrderSend(symbol,cmd,Volum,price,slippage,stoploss,takeprofit,comment,magic,expiration,arrow_color)
for example: OrderSend,EURUSD,OP_BUY,3,,5,,,,,0,MediumOrchid
i just use slippage 5 , expiration is 0 other is depend on you.
1 second later script is read your ordersend command from “commandfile.txt” and execute it.
if you want to close 1 lot of your 3 lots EURUSD order,
Amibroker read your open order from “openorders.txt” it seems like that
2017.06.27 17:00,O:4425436988,0,EURUSD,OP_BUY,3,1.12835,0,0
and amibroker write again to “commandfile.txt”
//" OrderClose",ticket,Volum,price,slippage,arrow_color)
for example: OrderClose,O:4425436988,1,,5,MediumOrchid
of course you have a new comment number for 2 lots EURUSD but every new ordersend or orderclose, openorders.txt
refreshing by script so that amibroker can read new comment number for your 2 lot EURUSD.
if you need uniqe number for your order, you have to assign magic number when you use ordersend command, i guess it is not change when you partilly close or modifiy your order but i did not test it.
Of course you have to create some button to select your open orders if it is more than ones.