closing blocks of trades

 

Hi guys,

I'm using satellite comms, so I can't spend much time searching and browsing, bit expensive.


What I need to do is close blocks of trades, say I have some buys open, say 0.01 lot, 0.05 lot and 0.14 lots = 0.2 lots total. Now I need to close 0.16 lots. So I would have to close a few trades and partially close the last one to meet my goal.


How do I do that? Anybody can point me to an article or even post some code. Would be greatly appreciated.


theMonkey

 
PumPuiMonkey:

Hi guys,

I'm using satellite comms, so I can't spend much time searching and browsing, bit expensive.

What I need to do is close blocks of trades, say I have some buys open, say 0.01 lot, 0.05 lot and 0.14 lots = 0.2 lots total. Now I need to close 0.16 lots. So I would have to close a few trades and partially close the last one to meet my goal. 

How do I do that? Anybody can point me to an article or even post some code. Would be greatly appreciated. 

It seems you know what needs to be done . . . what is you problem in doing it ?
 

Logic.

Easy to close a portion of a trade if the close order you send is smaller than the open trade, so send orderclose 0.01 to close and order that's 0.1 for example. But because of FIFA you need to close out the oldest first. So now I want to close 0.1 for example but my oldest trade is only 0.01, so now I go to close the thing, and then go onto the next one and keep going till I've closed what I wanted to close.

I had a few goes at it, but so far I haven't managed to accomplish it. And I'm very sure someone here has. So like to have a look at how it's done.

Reason: