Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Closing position unamanged apporach
Collapse
X
-
Closing position unamanged apporach
Hi, i'm trying to close the position with unmanaged apporach, but i don't get why it closes just half of my position and then shut down the strategy. I developed my own exitonsessionclosed() like in the photo. the fun thing is that in the output method I have 'disabling strategy ecc..' and then I have after the disabled strategy the Print() of the order average price. Thta i printed just to check if there were error in the order, what should it be? thanks
Tags: None
-
Hello AlessioCianini12,
The strategy is becoming automatically disabled? Or are you manually disabling it?
If the strategy is becoming automatically disabled, are there any errors on the Log tab of the Control Center?
If yes, please provide the full error message.
Note, an sell exit order would use the OrderAction.Sell (and not SellShort).Chelsea B.NinjaTrader Customer Service
-
Hi, It disable itself automatically, i don't do anything. Also I've already tried with orderaction.sell but stil itcloses half position : this is the error : Playback101: there is no market data available to drive the simulation engine. Afftected order Sell 1 market. But of course I have the data so it's not normal.thanks. In the log the error is:
Time Category Message
01/04/2022 11:31:26 Order Failed to submit orders: System.IndexOutOfRangeException: Index was outside the bounds of the array. at NinjaTrader.NinjaScript.StrategyBase.Process(Objec t sender, PositionEventArgs positionUpdate) at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at NinjaTrader.Cbi.Account.RaisePositionUpdate(Positi onEventArgs e) at NinjaTrader.Cbi.Account.PositionUpdateCallback(Ins trument instrument, MarketPosition marketPosition, Int32 quantity, Double averagePrice, Operation operation) at NinjaTrader.Cbi.Simulator.Fill(Int32 maxFillQuantity, Double price) at NinjaTrader.Cbi.Simulator.OnMarketData(Object sender, MarketDataEventArgs e) at NinjaTrader.Cbi.Simulator.OnTimerSubmitNow(Order order) at NinjaTrader.Cbi.Simulator.SubmitNow() at NinjaTrader.Cbi.Simulator.Submit() at NinjaTrader.Cbi.Account.Submit(IEnumerable`1 orders)
this is the log : The strategy was disabled before the orange line
This is the trace order:Last edited by AlessioCianini12; 04-01-2022, 04:50 AM.
Comment
-
Hello AlessioCianini12,
I'm not expecting an automatic disable before the message is received, but this could be a different issue.
Is CloseStrategy being used or SetState(State.Terminated)?
Could you make sure we are on the current version of the platform (Release 25) before proceeding?
Since this can be reproduced in Playback, could you implement that part of code, and just enough code to reproduce the issue in a separate test script that we can look at as well? Let us know the data to download as well, this should be as small as possible so we can more easily get to the issue at hand.
As much as the test script can be reduced can be helpful for us to review.
Exporting as source code - https://ninjatrader.com/support/help...tAsSourceFilesLast edited by NinjaTrader_Jim; 04-07-2022, 06:00 AM.
Comment
-
Hi, I solved it, apparently I had implement also an onPositionUpdate and tried to manage it as a whole, but apparently it is called each time the quantity increse and therefore I was having an error. The code above wasn't the problem, thanks.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
39 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
64 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
41 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment