NT Team,
An automated Strategy experienced a position limit error and eventually an unhandled exception.
Reviewing forum post "are there futures contract limits?" (https://ninjatrader.com/support/foru...ontract-limits), I confirm
- No Risk Template is applied to a Simulation account.
- Maximum position size does not feature on the NT Futures contract details (https://ninjatrader.com/PDF/ninjatra...ct_details.pdf).
- I will contact NTBrokerage for futher information. So far, I am unable to discern any information that helps with this problem (https://ninjatrader.com/Margins-Position-Management)
Please advise how the original position limit error occurred.
- At 4:11, 4 x 'HG 07-20' contracts were bought at Market.
- OnExecution, a stoploss, Stop Market, order was submitted.
- At 4:21, the stop was moved up
- At 4:27, the stop was moved up
- At 4:35, the stop move was rejected "Position limit for the contract F.US.CPE.N20 is 10, worst case position is 12"
Currently, the Strategy RealtimeErrorHandling = RealtimeErrorHandling.StopCancelCloseIgnoreRejects (http://ninjatrader.com/support/helpG...orhandling.htm)
protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment) { .... entry code etc... /* http://ninjatrader.com/support/helpGuides/nt8/en-us/realtimeerrorhandling.htm */ if (_stopOrder == null || _stopOrder != order) return; if (order.OrderState != OrderState.Rejected) return; Print("Rejection Handling"); // Stop loss order was rejected! Exit the position immediately at market var signalName = "Rejected by broker"; var fromEntrySignal = _orderName + "Entry"; _stopOrder = IsLong() ? ExitLong(ExecutionBarsArray, quantity, signalName, fromEntrySignal) : ExitShort(ExecutionBarsArray, quantity, signalName, fromEntrySignal); }
Please find below a summary of the Log file (the full file is 84MB with 561,000 rows) (there were no other open postions at during this event)
2020-06-10 04:11:58:025|1|16|NinjaScript strategy '###' submitting order 2020-06-10 04:11:58:059|1|32|Order='74b3feb2a3c146a4823b691a0b0eaa2f/###' Name='HG Entry' New state='Submitted' Instrument='HG 07-20' Action='Buy' Limit price=0 Stop price=0 Quantity=4 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:11:58:297|1|32|Order='1213023761/###' Name='HG Entry' New state='Accepted' Instrument='HG 07-20' Action='Buy' Limit price=0 Stop price=0 Quantity=4 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:11:58:297|1|32|Order='1213023761/###' Name='HG Entry' New state='Working' Instrument='HG 07-20' Action='Buy' Limit price=0 Stop price=0 Quantity=4 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:11:58:328|1|32|Order='1213023761/###' Name='HG Entry' New state='Filled' Instrument='HG 07-20' Action='Buy' Limit price=0 Stop price=0 Quantity=4 Type='Market' Time in force=GTC Oco='' Filled=4 Fill price=2.599 Error='No error' Native error='' 2020-06-10 04:11:58:329|1|16|NinjaScript strategy '###' submitting order 2020-06-10 04:11:58:329|1|8|Execution='317492747277' Instrument='HG 07-20' Account='###' Exchange=Nymex (New York Mercantile Exchange) Price=2.599 Quantity=4 Market position=Long Operation=Operation_Add Order='1213023761' Time='06/10/2020 04:11:58' 2020-06-10 04:11:58:356|1|32|Order='d7b939d23ebf4c36bb8fc7d9d6c49be7/###' Name='EntryBar100Pct' New state='Submitted' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.5955 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:11:58:414|1|64|Instrument='HG 07-20' Account='###' Average price=2.599 Quantity=4 Market position=Long Operation=Operation_Add 2020-06-10 04:11:58:590|1|32|Order='1213019303/###' Name='EntryBar100Pct' New state='Accepted' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.5955 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:11:58:591|1|32|Order='1213019303/###' Name='EntryBar100Pct' New state='Working' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.5955 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:21:06:502|1|16|NinjaScript strategy '###' submitting order 2020-06-10 04:21:06:545|1|32|Order='93921d3e3f3d4b06b62aa3be2fa6731a/###' Name='Bar75Pct5Min' New state='Submitted' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.597 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:21:06:781|1|32|Order='1213066852/###' Name='Bar75Pct5Min' New state='Accepted' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.597 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:21:06:784|1|32|Order='1213066852/###' Name='Bar75Pct5Min' New state='Working' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.597 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:27:56:911|1|16|NinjaScript strategy '###' submitting order 2020-06-10 04:27:56:949|1|32|Order='83262c2df60b435392cc99186d0c0d45/###' Name='BreakEven' New state='Submitted' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.599 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:27:57:179|1|32|Order='1213067436/###' Name='BreakEven' New state='Accepted' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.599 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:27:57:180|1|32|Order='1213067436/###' Name='BreakEven' New state='Working' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.599 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:35:04:267|1|16|NinjaScript strategy '###' submitting order 2020-06-10 04:35:04:340|1|32|Order='3d09b4154c6e410eae84c106a4297e94/###' Name='PenultimateExtreme' New state='Submitted' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.601 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:35:04:616|1|32|Order='3d09b4154c6e410eae84c106a4297e94/###' Name='PenultimateExtreme' New state='Rejected' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.601 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Order rejected' Native error='Position limit for the contract F.US.CPE.N20 is 10, worst case position is 12' The below four lines (or equivalent) repeated some 11,000 times, starting from 04:35:04 2020-06-10 04:35:04:618|1|16|NinjaScript strategy '###' submitting order 2020-06-10 04:35:04:619|0|32|###, Position limit for the contract F.US.CPE.N20 is 10, worst case position is 12 affected Order: Sell 4 StopMarket @ 2.601 2020-06-10 04:35:04:675|1|32|Order='0874d3a0f992493389edbf409ae9a093/###' Name='Rejected by broker' New state='Submitted' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=0 Quantity=4 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2020-06-10 04:35:04:921|1|32|Order='0874d3a0f992493389edbf409ae9a093/###' Name='Rejected by broker' New state='Rejected' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=0 Quantity=4 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Order rejected' Native error='Position limit for the contract F.US.CPE.N20 is 10, worst case position is 12' … 2020-06-10 05:53:08:535|1|32|Order='1213067436/###' Name='BreakEven' New state='Filled' Instrument='HG 07-20' Action='Sell' Limit price=0 Stop price=2.599 Quantity=4 Type='Stop Market' Time in force=GTC Oco='' Filled=4 Fill price=2.5975 Error='No error' Native error='' 2020-06-10 05:53:08:543|1|8|Execution='317550636557' Instrument='HG 07-20' Account='###' Exchange=Nymex (New York Mercantile Exchange) Price=2.5975 Quantity=4 Market position=Short Operation=Operation_Add Order='1213067436' Time='06/10/2020 05:53:08' 2020-06-10 05:53:09:962|1|32|Order='1213066852/###' Name='Bar75Pct5Min' New state='Cancel submitted' ... 2020-06-10 05:53:10:103|1|32|Order='1213019303/###' Name='EntryBar100Pct' New state='Cancel submitted' ... 2020-06-10 05:53:10:272|1|64|Instrument='HG 07-20' Account='###' Average price=0 Quantity=0 Market position=Short Operation=Remove 2020-06-10 05:53:10:610|1|32|Order='1213066852/###' Name='Bar75Pct5Min' New state='Cancelled' Instrument='HG 07-20' Action='Sell' ... 2020-06-10 05:53:11:046|1|32|Order='1213019303/###' Name='EntryBar100Pct' New state='Cancelled' Instrument='HG 07-20' Action='Sell' ... The below line repeated some 516,000 times, starting from 06:39:18 2020-06-10 06:39:18:409|0|4|Unhandled exception: The current process has used all of its system allowance of handles for Window Manager objects … 2020-06-10 10:22:48:798|3|2|Connection lost to the NinjaTrader Historical Data Server: hds-us-nt-003.ninjatrader.com
Comment