I have done extensive testing on this code on the SIM account which has worked fine. However, the first time I have moved it to a live account the stop movement code is just ignored.
I know this is my debug but this is what it is meant to look like:
NQ,30/01/20 07:00:10,Attempting "2x16T,60T,25S,16B-ET,-5B-ES" Entry LONG - Current state Flat
NQ,30/01/20 07:00:10,Strategy "1a5e2b5e257143558764478d8f0b1cd9" --> New Order process state: Requested
NQ,30/01/20 07:00:10,Strategy "1a5e2b5e257143558764478d8f0b1cd9" --> New Order process state: Created
NQ,30/01/20 07:00:10,The entry order status is: Submitted
NQ,30/01/20 07:00:10,The entry order status is: Submitted
NQ,30/01/20 07:00:10,The entry order status is: Submitted
NQ,30/01/20 07:00:10,The entry order status is: Submitted
NQ,30/01/20 07:00:10,The entry order status is: Filled
NQ,30/01/20 07:00:10,Strategy "1a5e2b5e257143558764478d8f0b1cd9" --> New Order process state: Filled
NQ,30/01/20 07:00:10,ATM Strategy: "2x16T,60T,25S,16B-ET,-5B-ES" with stop at 9044.75
NQ,30/01/20 07:00:10,The entry order average fill price is: 9053.63 -- order requested at 9053.50
NQ,30/01/20 07:00:10,The entry order filled amount is: 2
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) updating stops for 2 contracts to 9044.75
NQ,30/01/20 07:00:10,Strategy "1a5e2b5e257143558764478d8f0b1cd9" --> New Order process state: AdjustStops
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop1 to 9044.75
NQ,30/01/20 07:00:10,Current state is Initialized
NQ,30/01/20 07:00:10,Stop1 not yet Accepted
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop1 to 9044.75
NQ,30/01/20 07:00:10,Current state is Submitted
NQ,30/01/20 07:00:10,Stop1 not yet Accepted
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop1 to 9044.75
NQ,30/01/20 07:00:10,Current state is Submitted
NQ,30/01/20 07:00:10,Stop1 not yet Accepted
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop1 to 9044.75
NQ,30/01/20 07:00:10,Current state is Submitted
NQ,30/01/20 07:00:10,Stop1 not yet Accepted
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop1 to 9044.75
NQ,30/01/20 07:00:10,Current state is Submitted
NQ,30/01/20 07:00:10,Stop1 not yet Accepted
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop1 to 9044.75
NQ,30/01/20 07:00:10,Current state is Submitted
NQ,30/01/20 07:00:10,Stop1 not yet Accepted
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop1 to 9044.75
NQ,30/01/20 07:00:10,Current state is Accepted
NQ,30/01/20 07:00:10,AtmStrategyChangeStopTarget - looks ok
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop2 to 9044.75
NQ,30/01/20 07:00:10,Current state is Submitted
NQ,30/01/20 07:00:10,Stop2 not yet Accepted
NQ,30/01/20 07:00:10,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (1a5e2b5e257143558764478d8f0b1cd9) attempting update Stop2 to 9044.75
NQ,30/01/20 07:00:10,Current state is Accepted
NQ,30/01/20 07:00:10,AtmStrategyChangeStopTarget - looks ok
NQ,30/01/20 07:00:10,Strategy "1a5e2b5e257143558764478d8f0b1cd9" --> New Order process state: Working
NQ,30/01/20 07:00:25,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES ended for -355.00 loss
NQ,30/01/20 07:00:25,Strategy "1a5e2b5e257143558764478d8f0b1cd9" --> New Order process state: Flat
On the live account the STATE never goes to 'Accepted' and my code simply keeps waiting for it to change:
NQ,30/01/20 13:54:31,Attempting "2x16T,60T,25S,16B-ET,-5B-ES" Entry SHORT - Current state Flat
NQ,30/01/20 13:54:31,Strategy "0c3abf99b3d1404d95d7df6a40495b7e" --> New Order process state: Requested
NQ,30/01/20 13:54:31,Strategy "0c3abf99b3d1404d95d7df6a40495b7e" --> New Order process state: Created
NQ,30/01/20 13:54:31,The entry order status is: Initialized
NQ,30/01/20 13:54:32,The entry order status is: Submitted
NQ,30/01/20 13:54:32,The entry order status is: Submitted
NQ,30/01/20 13:54:32,The entry order status is: Submitted
NQ,30/01/20 13:54:32,The entry order status is: Submitted
NQ,30/01/20 13:54:32,The entry order status is: Filled
NQ,30/01/20 13:54:34,Strategy "0c3abf99b3d1404d95d7df6a40495b7e" --> New Order process state: Filled
NQ,30/01/20 13:54:34,ATM Strategy: "2x16T,60T,25S,16B-ET,-5B-ES" with stop at 9063.50
NQ,30/01/20 13:54:34,The entry order average fill price is: 9053.25 -- order requested at 9053.00
NQ,30/01/20 13:54:34,The entry order filled amount is: 2
NQ,30/01/20 13:54:34,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (0c3abf99b3d1404d95d7df6a40495b7e) updating stops for 2 contracts to 9063.50
NQ,30/01/20 13:54:34,Strategy "0c3abf99b3d1404d95d7df6a40495b7e" --> New Order process state: AdjustStops
NQ,30/01/20 13:54:34,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (0c3abf99b3d1404d95d7df6a40495b7e) attempting update Stop1 to 9063.50
NQ,30/01/20 13:54:34,Current state is Working
NQ,30/01/20 13:54:34,Stop1 not yet Accepted
NQ,30/01/20 13:54:34,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (0c3abf99b3d1404d95d7df6a40495b7e) attempting update Stop1 to 9063.50
NQ,30/01/20 13:54:34,Current state is Working
NQ,30/01/20 13:54:34,Stop1 not yet Accepted
NQ,30/01/20 13:54:34,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (0c3abf99b3d1404d95d7df6a40495b7e) attempting update Stop1 to 9063.50
NQ,30/01/20 13:54:34,Current state is Working
NQ,30/01/20 13:54:34,Stop1 not yet Accepted
************************** LOTS OF LINES REMOVED
NQ,30/01/20 13:58:55,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (0c3abf99b3d1404d95d7df6a40495b7e) attempting update Stop1 to 9063.50
NQ,30/01/20 13:58:55,Current state is Working
NQ,30/01/20 13:58:55,Stop1 not yet Accepted
NQ,30/01/20 13:58:55,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (0c3abf99b3d1404d95d7df6a40495b7e) attempting update Stop1 to 9063.50
NQ,30/01/20 13:58:55,Current state is Working
NQ,30/01/20 13:58:55,Stop1 not yet Accepted
NQ,30/01/20 13:58:55,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES (0c3abf99b3d1404d95d7df6a40495b7e) attempting update Stop1 to 9063.50
NQ,30/01/20 13:58:55,Current state is Working
NQ,30/01/20 13:58:55,Stop1 not yet Accepted
NQ,30/01/20 13:58:55,Strategy "0c3abf99b3d1404d95d7df6a40495b7e" --> New Order process state: Closing
NQ,30/01/20 13:58:55,ATM Strategy: 2x16T,60T,25S,16B-ET,-5B-ES ended for -250.00 loss
NQ,30/01/20 13:58:55,Strategy "0c3abf99b3d1404d95d7df6a40495b7e" --> New Order process state: Flat
Am I missing something here? Is the STATE sequence different for SIM and LIVE accounts?
Also, I've looked at the logs and it seems like the request to change the Stops isn't even submitted. Relevant section:
2020-01-30 13:54:32:116|1|32|Order='99b63a6bab074db3a5d92e346 8ad3863/J8659' Name='Entry' New state='Submitted' Instrument='NQ 03-20' Action='Sell' Limit price=0 Stop price=0 Quantity=2 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:385|1|32|Order='723458417/J8659' Name='Entry' New state='Accepted' Instrument='NQ 03-20' Action='Sell' Limit price=0 Stop price=0 Quantity=2 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:385|1|32|Order='723458417/J8659' Name='Entry' New state='Working' Instrument='NQ 03-20' Action='Sell' Limit price=0 Stop price=0 Quantity=2 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:457|1|32|Order='723458417/J8659' Name='Entry' New state='Filled' Instrument='NQ 03-20' Action='Sell' Limit price=0 Stop price=0 Quantity=2 Type='Market' Time in force=GTC Oco='' Filled=2 Fill price=9053.25 Error='No error' Native error=''
2020-01-30 13:54:32:461|1|8|Execution='291544827392' Instrument='NQ 03-20' Account='J8659' Exchange=Globex Price=9053.25 Quantity=2 Market position=Short Operation=Operation_Add Order='723458417' Time='01/30/2020 13:54:32'
2020-01-30 13:54:32:463|1|64|Instrument='NQ 03-20' Account='J8659' Average price=9053.25 Quantity=2 Market position=Short Operation=Operation_Add
2020-01-30 13:54:32:465|1|32|Order='ca5dced986df42e9bfbea97af 2569501/J8659' Name='Stop1' New state='Submitted' Instrument='NQ 03-20' Action='Buy to cover' Limit price=0 Stop price=9059.5 Quantity=1 Type='Stop Market' Time in force=DAY Oco='e48d1ce4616047d5a68cad59c70ee752' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:467|1|32|Order='fe9463c45df94b5eb6673b5e6 4f5e138/J8659' Name='Target1' New state='Submitted' Instrument='NQ 03-20' Action='Buy to cover' Limit price=9049.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='e48d1ce4616047d5a68cad59c70ee752' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:468|1|32|Order='84dae512a5b44effa2e3238f1 b7ce2f6/J8659' Name='Stop2' New state='Submitted' Instrument='NQ 03-20' Action='Buy to cover' Limit price=0 Stop price=9059.5 Quantity=1 Type='Stop Market' Time in force=DAY Oco='5c8990eb48184c57b47d3f81351e6e43' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:468|1|32|Order='5dbb93a5154c493f8e0b3748e 6f7920f/J8659' Name='Target2' New state='Submitted' Instrument='NQ 03-20' Action='Buy to cover' Limit price=9038.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='5c8990eb48184c57b47d3f81351e6e43' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:758|1|32|Order='723615329/J8659' Name='Stop1' New state='Accepted' Instrument='NQ 03-20' Action='Buy to cover' Limit price=0 Stop price=9059.5 Quantity=1 Type='Stop Market' Time in force=DAY Oco='e48d1ce4616047d5a68cad59c70ee752' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:758|1|32|Order='723615329/J8659' Name='Stop1' New state='Working' Instrument='NQ 03-20' Action='Buy to cover' Limit price=0 Stop price=9059.5 Quantity=1 Type='Stop Market' Time in force=DAY Oco='e48d1ce4616047d5a68cad59c70ee752' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:758|1|32|Order='723610284/J8659' Name='Stop2' New state='Accepted' Instrument='NQ 03-20' Action='Buy to cover' Limit price=0 Stop price=9059.5 Quantity=1 Type='Stop Market' Time in force=DAY Oco='5c8990eb48184c57b47d3f81351e6e43' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:758|1|32|Order='723610284/J8659' Name='Stop2' New state='Working' Instrument='NQ 03-20' Action='Buy to cover' Limit price=0 Stop price=9059.5 Quantity=1 Type='Stop Market' Time in force=DAY Oco='5c8990eb48184c57b47d3f81351e6e43' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:759|1|32|Order='723507478/J8659' Name='Target1' New state='Accepted' Instrument='NQ 03-20' Action='Buy to cover' Limit price=9049.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='e48d1ce4616047d5a68cad59c70ee752' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:759|1|32|Order='723507478/J8659' Name='Target1' New state='Working' Instrument='NQ 03-20' Action='Buy to cover' Limit price=9049.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='e48d1ce4616047d5a68cad59c70ee752' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:759|1|32|Order='723507479/J8659' Name='Target2' New state='Accepted' Instrument='NQ 03-20' Action='Buy to cover' Limit price=9038.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='5c8990eb48184c57b47d3f81351e6e43' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:54:32:759|1|32|Order='723507479/J8659' Name='Target2' New state='Working' Instrument='NQ 03-20' Action='Buy to cover' Limit price=9038.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='5c8990eb48184c57b47d3f81351e6e43' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:58:55:350|1|32|Order='723615329/J8659' Name='Stop1' New state='Filled' Instrument='NQ 03-20' Action='Buy to cover' Limit price=0 Stop price=9059.5 Quantity=1 Type='Stop Market' Time in force=DAY Oco='e48d1ce4616047d5a68cad59c70ee752' Filled=1 Fill price=9059.5 Error='No error' Native error=''
2020-01-30 13:58:55:354|1|8|Execution='291549029632' Instrument='NQ 03-20' Account='J8659' Exchange=Globex Price=9059.5 Quantity=1 Market position=Long Operation=Operation_Add Order='723615329' Time='01/30/2020 13:58:55'
2020-01-30 13:58:55:354|1|32|Order='723610284/J8659' Name='Stop2' New state='Filled' Instrument='NQ 03-20' Action='Buy to cover' Limit price=0 Stop price=9059.5 Quantity=1 Type='Stop Market' Time in force=DAY Oco='5c8990eb48184c57b47d3f81351e6e43' Filled=1 Fill price=9059.5 Error='No error' Native error=''
2020-01-30 13:58:55:354|1|32|Order='723507478/J8659' Name='Target1' New state='Cancelled' Instrument='NQ 03-20' Action='Buy to cover' Limit price=9049.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='e48d1ce4616047d5a68cad59c70ee752' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:58:55:354|1|32|Order='723507479/J8659' Name='Target2' New state='Cancelled' Instrument='NQ 03-20' Action='Buy to cover' Limit price=9038.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='5c8990eb48184c57b47d3f81351e6e43' Filled=0 Fill price=0 Error='No error' Native error=''
2020-01-30 13:58:55:354|1|8|Execution='291549030144' Instrument='NQ 03-20' Account='J8659' Exchange=Globex Price=9059.5 Quantity=1 Market position=Long Operation=Operation_Add Order='723610284' Time='01/30/2020 13:58:55'
2020-01-30 13:58:55:459|1|64|Instrument='NQ 03-20' Account='J8659' Average price=0 Quantity=0 Market position=Short Operation=Remove
Regards,
Steve
P.S. In writing and checking this long post I now believe I can see what is wrong. It would appear that the STATE sequence for Stops is different for SIM and LIVE. I see now that LIVE is returning 'Working' as opposed to 'Accepted' and therefore my code does NOT submit the request to change the Stop. So of course it never happens. Apologies for this long post, but it has helped me understand. I would appreciate you confirming that the STATE sequences are slightly different. Can you clarify what state I should wait for BEFORE submitting the Stop change request.
Thanks.
Comment