The help guide says the following...
"Methods that generate orders (excluding market orders) to enter a position will be ignored if:
1. A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
2. A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
3. The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction "
So there are 3 scenarios that can cause this. To handle scenario #1 and #3 I've added code to cancel all orders before sending an entry order. I don't use any set methods in the code so scenario #2 cannot be the cause. My code is very simple, I have 2 entries, 2 stops, and 2 profit targets (1 each for long and short). This is my code for entering long trades. It is the same structure as used in entering short trades.
if (mycondition && Positions[0].MarketPosition!=MarketPosition.Long) { if (Close[0]<orderprice) { if (SEntry!=null) CancelOrder(SEntry); if (SProfit!=null) CancelOrder(SProfit); if (SStop!=null) CancelOrder(SStop); LEntry=EnterLongStop(orderprice); } }
Comment