This what I use.
You may have to change it to suit your needs.
Thanks for your response Donald but my situation is a bit more complex. If there is a big gap up in the cross rate (due to a Fed statement, etc.) I can have 3 or 4 limit orders executed at the same price and time. I can't embed a value in the Comment field either since the limit orders may not have been created sequentially. I can code around this but it requires multiple array passes and array resizes which consumes cycles and is not desirable in a fast moving market.
Initial State (Cross Rate 1.0795):
Limit 4 - 1.0815
Limit 3 - 1.0810
Limit 2 - 1.0805
Limit 1 - 1.08
State 2 (Cross Rate 1.080):
Open Order 1 - 1.080
State 3 (Cross Rate 1.0790 - TP Order 1):
Close Order 1 - 1.0790
Limit 5 - 1.08 (Replaces original Limit 1)
State 4 (Gaps up to 1.0812 & all open orders have same OpenTime):
Open Order 3 - 1.08120
Open Order 2 - 1.08120
Open Order 5 - 1.08120
Programatically how do I determine FIFO?