I'm doing live simulations of a simple Strategy that runs under unmanaged approach, which eventually submits limit orders with prices that most of the time matches or pass the best Bid or Ask. The chosen instrument to run the live simulations is the EURUSD cash. The data connection is to IB through the latest TWS ( build 967.1f ). So here an example:
I start the Strategy, it's synchronized to a 100.000 Long position, and then a pops up a sell signal that indicates: Reverse Position; so a sell limit order is submitted, here a code extract used:
if ( psignal > 0 ) { // Open or Reverse to a Long position } if ( psignal < 0 ) { // Open or Reverse to a Short position // Determines the position and submit the order needed. if ( ( Position.MarketPosition == MarketPosition.Long || Position.MarketPosition == MarketPosition.Flat || (Position.MarketPosition == MarketPosition.Short && Qty > Position.Quantity) ) ) { if ( setshort == null ) { sellprice = GetCurrentBid(); if ( Position.MarketPosition == MarketPosition.Long ) { setshort = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, (Qty+Position.Quantity), sellprice, 0, "", "SHORT"); } else if ( Position.MarketPosition == MarketPosition.Flat || (Position.MarketPosition == MarketPosition.Short && Qty > Position.Quantity) ) { setshort = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, (Qty-Position.Quantity), sellprice, 0, "", "SHORT"); } else { } } } }
Sim101, Limit price can't be smaller than current bid. affected Order: Sell 200000 Limit @ 1.18473
Working with forex, at 1/10 pips, ticks go pretty fast and change constantly, so it's normally expected that whenever an order is submitted at the best Bid or Ask of the moment, milliseconds later, don't match exactly with the new Bid or Ask, most of the time the order price overpass them, under this circumstance they should get filled immediately or pretty fast, and not get rejected because it doesn't match exactly the Bid or Ask. So, this is giving me a hard time cause I don't know if it's only a simulator issue, or even worse, that it would happen as well working with a real broker account.
So, I'm looking forward of your ideas, suggestions, trials, or solution for this issue.
Thanks in advance
Comment