Using Net Orders for FIFO accounts
Brief
The article describes how to handle risk management using net orders on FIFO accounts
Details
The first approach is to recognize all the amount kept on the particular instrument/account (for example all EUR/USD positions on account 0001) as one "netting" position. The open price of the netting position is average weighted price of all the orders executed:
AverageWeigtedPrice := SUM(OpenOrderAmount * OpenOrderPrice) / OpenOrderCount;
So, in this approach you don't need to close any particular position, you can just close fully or partially the one existing positions.
For this approach you can use the following "netting" modification of orders:
1) Netting Close orders. The netting close orders closes all the existing amount on the specified account/instrument. It is created just as the regular close order, but does not require the TradeID, so, it closes everything which exist on the specified account and instrument at the moment of the order execution.
2) If you need to close the position partially - just execute an opposite open order.
3) Use "netting" modification of the Entry Stop and Limit orders. If netting flag is specified, such entry orders will close all the amount existing on the specified account and instrument at the moment when order is filled. The netting entry direction must be opposite to the netting position held on the amount at the moment of the order creation.
The only limitation with "netting" stop and limits are:
a) The netting orders can be created only in the moment when at least position actually exist on the account. You cannot create such orders "in advance" and activate them automatically when position is created. So, during the period when position is already created, but your application hasn't detected it and created the entry, the position is on the market without any risk-management orders.
b) "Netting orders" can close only full amount held on the account/instrument at the moment. They cannot close such position partially.
In case you want to avoid such limitations, please use ELS orders.