I have a multi instrument strategy that takes pairs trades on BarsArray[1] and BarsArray[2], but never on BarsArray[0].
The instrument in BarsArray[2] is always the same as the chart instrument.
It is working well.
However I am having difficulties with the WAIT UNTIL FLAT BEFORE EXECUTING LIVE option. This doesn't appear to work correctly on my strategy.
If I have a pair of virtual trades open when I start the strategy, one of them will WAIT UNTIL FLAT, but the other one - on BarsInProgress==2 - will create a real order and real Strategy Position using an Exit() order.
Here is the log of a trade creating a real position using an Exit() order....
07-Aug-09 7:44:02 AM|1|128|Starting NinjaScript strategy 'JRPairsTraderRT/fcc7f251c317488d9da27602ace99d7b' : On starting a real-time strategy - StrategySync=WaitUntilFlat EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=ByStrategyPosition ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 135 before close Set order quantity by=Strategy
07-Aug-09 1:58:31 PM|1|32|Order='71758bd371f446f88b4d566a381c4f80/Sim101' Name='UberZTarget' New State=PendingSubmit Instrument='ES ##-##' Action=BuyToCover Limit price=0 Stop price=0 Quantity=11 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
07-Aug-09 1:58:31 PM|1|32|Order='71758bd371f446f88b4d566a381c4f80/Sim101' Name='UberZTarget' New State=Accepted Instrument='ES ##-##' Action=BuyToCover Limit price=0 Stop price=0 Quantity=11 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
07-Aug-09 1:58:31 PM|1|32|Order='71758bd371f446f88b4d566a381c4f80/Sim101' Name='UberZTarget' New State=Working Instrument='ES ##-##' Action=BuyToCover Limit price=0 Stop price=0 Quantity=11 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
07-Aug-09 1:58:31 PM|1|32|Order='71758bd371f446f88b4d566a381c4f80/Sim101' Name='UberZTarget' New State=Filled Instrument='ES ##-##' Action=BuyToCover Limit price=0 Stop price=0 Quantity=11 Type=Market Filled=11 Fill price=1012.25 Error=NoError Native error=''
07-Aug-09 1:58:31 PM|1|16|Execution='eab60c8fffcf48649c090d33de6fd9e b' Instrument='ES ##-##' Account='Sim101' Exchange=Default Price=1012.25 Quantity=11 Market position=Long Operation=Insert Order='71758bd371f446f88b4d566a381c4f80' Time='07-Aug-09 1:58:31 PM'
07-Aug-09 1:58:31 PM|1|64|Instrument='ES ##-##' Account='Sim101' Avg price=1012.25 Quantity=11 Market position=Long Operation=Insert Currency=Unknown
You can see that a "BuyToCover" order generated a real Long position.
How precisely is the virtual "FLAT" position determined? Does it only examine the first BarsInProgress ? If so, and there is no position there but positions in other BarsInProgress, this test would fail.
Hoping you can help.
saltminer

Comment