Hatori.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
GetAtmStrategyMarketPosition failing randomly
Collapse
X
-
GetAtmStrategyMarketPosition failing randomly
Sometimes the GetAtmStrategyMarketPosition report flat when the atm is in position. I attached a sample strategy where you can test this out. Usually on second or third filled entry the GetAtmStrategyMarketPosition report flat, and a new atm enter while there is already an atm present with an open position.
Hatori.Tags: None
-
I was not able to reproduce here on my end, tried for example on the ES 15 sec chart to get some trades quickly in - please do this, try the same chart and our default SampleAtmStrategy, open output window up and wait until the strategy gets filled?
Does it report ok?
Then while still in the trade and the exit bracket is working, please add manually one contract via a Market Buy Order from the DOM for example -
Does this get reported ok as well?
Comment
-
GetAtmStrategyMarketPosition
I tried again and add timestamp to the print: you can see that the ATM order is filled (at 22:36:45) and right away the
GetAtmStrategyMarketPosition report flat status (check the code where that print is) , and then an over-entry occurs.
I am almost sure that you can reproduce this with attached sample.
That code (and the strategy which is based on that) is working perfectly in NT6.5 for a very long time.
Comment
-
hatori, if the order just filled (like in your shown sample) there's no guarantee that the position update at that point is indeed done, it would be for sure showing after the next subsequent OnBarUpdate() call, so you would have let your test run one bar longer before disabling to see it being reflected.
Comment
-
The flat print came form the next subsequent OnBarUpdate() call , also please notice that this is not a custom code , we are talking about your basic atm sample with an extra print , and CalculateOnClose set to false.
Not clear why is it working in NT6.5 and fail in NT7 , pure luck?
Comment
-
hatori,
This is working as expected. This is the same in 6.5 and 7. There is no guarantee GetAtmStrategyMarketPosition() will be updated until the next OnBarUpdate() event. If you see it get updated earlier than the next OnBarUpdate(), great, but it is not guaranteed to be updated until the next OnBarUpdate() event.Josh P.NinjaTrader Customer Service
Comment
-
Hello,
You've got an extra
GetAtmStrategyMarketPosition
call which is not present in the basic sample eighter, without that , it is happening all the time.
If I understand right , that extra call is doing some sync in the background , so on the next OnBarUpdate the function return with the correct value.
Comment
-
hatori,
Please do not strip away the print outs from outside the if-statement. Those are necessary to see the relationship of the next OnBarUpdate() event versus GetAtmStrategyMarketPosition().
This is the output of your version with me disabling it a minute after the entry is filled. Once entry is filled the strategy stops producing any useful output:
Even with removing the GetAtmStrategyMarketPosition check inside the status.GetLength(0) > 0 if-statement does not make a difference of this behavior. There is no "atmStrategyId reset" call on the next OnBarUpdate(). Please be sure you are on NT7B17. We are testing with Simulated Data Feed on our end.Code:0039 22:26:53.12 Working Flat 0040 22:26:53.62 Working Flat 0041 22:26:54.12 Filled Flat **NT** Disabling NinjaScript strategy 'Atm3/aa6f7992f39149eebcb02c2a9062bf85'
Output with the "extra" code commented out (attached below).
Code:------- START 5 ------- 22:32:51.81 Working Flat 22:32:51.81 The current ATM Strategy market position is: Flat ------- END 5 ------- ------- START 6 ------- 22:32:52.36 Filled Flat 22:32:52.36 The current ATM Strategy market position is: Flat ------- END 6 ------- ------- START 7 ------- 22:32:52.84 The current ATM Strategy market position is: Long ------- END 7 -------
Attached FilesJosh P.NinjaTrader Customer Service
Comment
-
I do not have more time for this. It is still happening easily. What I can suggest to reproduce: wait for a sudden , at least two tick move , and do not call GetAtmStrategyMarketPosition on the same OnBarUpdate event when you trigger the ATM . Call GetAtmStrategyMarketPosition only when the strategyId is not null.
Regards,
Hatori.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
599 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
345 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
558 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
558 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment