avoiding FIFO snafu.

 

Hello community,

When making a robot, is it possible to program a robot in such a way that it can determine FIFO for positions of the same size and instrument in the same account?

If, for example, I have 7 positions of the same size and instrument in one account, with seven robots on seven screens, and a robot tries to send a signal to close, can it be programmed to discern which position was taken first, and close the same at market?

I set my Magic Number to zero for my robots, which does mostly work, but should the market move quickly, 2 or 3 robots can send a trade signal to close a position at the same time. I'll get a FIFO violation, and the trade will not execute, or will close late.

Any suggestions?

 
maxbilllzzz:

Hello community,

When making a robot, is it possible to program a robot in such a way that it can determine FIFO for positions of the same size and instrument in the same account?

If, for example, I have 7 positions of the same size and instrument in one account, with seven robots on seven screens, and a robot tries to send a signal to close, can it be programmed to discern which position was taken first, and close the same at market?

I set my Magic Number to zero for my robots, which does mostly work, but should the market move quickly, 2 or 3 robots can send a trade signal to close a position at the same time. I'll get a FIFO violation, and the trade will not execute, or will close late.

Any suggestions?

Yes, it is possible but its complex. Also, you should not use the magic number "0" for EAs as that is reserved for manual trades.
 
Good to know, thanks, Fernando.
 
Fernando Carreiro #:
Yes, it is possible but its complex. Also, you should not use the magic number "0" for EAs as that is reserved for manual trades.

Really I am curious to know how it's possible ?

EA 1 open a trade. EA 2 open a trade. Same symbol and direction of course.

EA 2 want to close his trade, he can't by FIFO rules. How could you possibly manage that even in a "complex" way ? And of course without multiplying the open/close with a spread each time (as of course you can close EA1 trade, then EA2 trade, then open EA1 trade again, which is not a solution in my opinion).

 
Ha. That's like 2 years old.

But I suspect, it's not about changing the FIFO sequence, but about assigning the positions to the corresponding EA.

In other words, if you look at the open times of the position, it should be possible to select the right position to execute the close. And if these positions are directly linked to the EA, each EA needs to know it's position in the FIFO queue.

This way it would be possible to add points to the close price of each closing order according to the position in the queue. Of course this would need a pending order or an adjusted TP on the position.

Please correct me if I am wrong.