The script is capable to reverse positions under unmanaged approach method. This is the logic flow when a reverse triggers:
- Cancelling any working order which intends to increase the Old Position
- Cancelling any working order which would intend to Exit the New Position
- Enter Exit Old Position order
if this order is filled
{
Cancel the the stop loss order for the Old Position
Enter order for the New Position
}
Note: all the required programming steps for correctly internal managing the state of orders are Ok.
When Script runs, it opens OK, reverses perfectly from Long to Short, BUT when it comes to reverse from Short to Long, a weird error happens. The Long position is entered and filled, but its StopLoss doesn't. From that point the Script seems to continue OK, but it really doesn't. Obviously all reverse routine for Short and Long are exactly the same, like mirror images. The error obviously involves the next StopLoss order. The only thing that I suspect is that may be there's some electronic ban or interference for new orders sent while other are marked to be cancelled despite are different ( should I confirm orders's states before launching new orders ? This could really slowdown the filling dynamics of the script in a competitive market like E-mini S&P500). Here's an extract from Log file where this could be seen.
HERE BEGINS THE REVERSE COMMENTED
20/12/2013 15:59:56|1|32|Order='9e24d5759f4b4ad1835aaa9d686d0 a4d/Sim101' Name='Exit Short' New state=PendingSubmit Instrument='ES 03-14' Action=BuyToCover Limit price=1813.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
20/12/2013 15:59:56|1|32|Order='9e24d5759f4b4ad1835aaa9d686d0 a4d/Sim101' Name='Exit Short' New state=Accepted Instrument='ES 03-14' Action=BuyToCover Limit price=1813.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
20/12/2013 15:59:56|1|32|Order='9e24d5759f4b4ad1835aaa9d686d0 a4d/Sim101' Name='Exit Short' New state=Working Instrument='ES 03-14' Action=BuyToCover Limit price=1813.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
20/12/2013 15:59:56|1|32|Order='9e24d5759f4b4ad1835aaa9d686d0 a4d/Sim101' Name='Exit Short' New state=Filled Instrument='ES 03-14' Action=BuyToCover Limit price=1813.25 Stop price=0 Quantity=1 Type=Limit Filled=1 Fill price=1813.25 Error=NoError Native error=''
20/12/2013 15:59:56|1|16|Execution='3034d6b0edba4c5a8753c3212 4aaa738' Instrument='ES 03-14' Account='Sim101' Exchange=Default Price=1813.25 Quantity=1 Market position=Long Operation=Insert Order='9e24d5759f4b4ad1835aaa9d686d0a4d' Time='20/12/2013 15:59:56'
20/12/2013 15:59:56|1|64|Instrument='ES 03-14' Account='Sim101' Avg price=1813.25 Quantity=0 Market position=Short Operation=Remove Currency=Unknown
20/12/2013 15:59:56|1|32|Order='29c4f85ecc9746eab2a5ff842c129 d29/Sim101' Name='Enter Stop Short' New state=PendingCancel Instrument='ES 03-14' Action=BuyToCover Limit price=0 Stop price=1821.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
20/12/2013 15:59:56|1|32|Order='e30ef0e89df348419e477f4526e3a e0c/Sim101' Name='Enter Long' New state=PendingSubmit Instrument='ES 03-14' Action=Buy Limit price=1813.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
20/12/2013 15:59:56|3|128|Error on calling 'OnExecution' method for strategy 'CRBSsimpleUmanaged/fa8e29a86fb7413c872c9f38f4e10f39': Referencia a objeto no establecida como instancia de un objeto.
20/12/2013 15:59:57|1|32|Order='e30ef0e89df348419e477f4526e3a e0c/Sim101' Name='Enter Long' New state=Accepted Instrument='ES 03-14' Action=Buy Limit price=1813.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
20/12/2013 15:59:57|1|32|Order='e30ef0e89df348419e477f4526e3a e0c/Sim101' Name='Enter Long' New state=Working Instrument='ES 03-14' Action=Buy Limit price=1813.25 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
20/12/2013 15:59:57|1|32|Order='29c4f85ecc9746eab2a5ff842c129 d29/Sim101' Name='Enter Stop Short' New state=Cancelled Instrument='ES 03-14' Action=BuyToCover Limit price=0 Stop price=1821.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
20/12/2013 15:59:57|1|32|Order='e30ef0e89df348419e477f4526e3a e0c/Sim101' Name='Enter Long' New state=Filled Instrument='ES 03-14' Action=Buy Limit price=1813.25 Stop price=0 Quantity=1 Type=Limit Filled=1 Fill price=1813.25 Error=NoError Native error=''
20/12/2013 15:59:57|1|16|Execution='93bb90f952b2424db8da684c4 aaf3aa6' Instrument='ES 03-14' Account='Sim101' Exchange=Default Price=1813.25 Quantity=1 Market position=Long Operation=Insert Order='e30ef0e89df348419e477f4526e3ae0c' Time='20/12/2013 15:59:57'
20/12/2013 15:59:57|1|64|Instrument='ES 03-14' Account='Sim101' Avg price=1813.25 Quantity=1 Market position=Long Operation=Insert Currency=Unknown
20/12/2013 16:14:30|1|128|Exit on close handling for strategy 'CRBSsimpleUmanaged' started.
Any ideas or suggestion about this?
Thanks in advanced
Comment