private void Reset()
{
PrintOutput(String.Format("Exit | {0}", _entryName));
_entryLong = false;
_entryShort = false;
_entryName = "";
_atmStrategyId = null;
_isAtmStrategyCreated = false;
ResetTradeDirection();
// Prevent re-entry on previous exit bar
_lastTradeBarNumber = _dataBars.Bar.BarNumber + 1;
}
private void CheckAtmStrategies()
{
if (State < State.Realtime || BackTestingEnabled)
{
return;
}
if (_isAtmStrategyCreated)
{
// Position was created and exited
if (AtmIsFlat() && (_orderFlowBotState.ValidStrategyDirection == Direction.Long ||
_orderFlowBotState.ValidStrategyDirection == Direction.Short))
{
Reset();
ControlPanelOnExecutionUpdate();
}
}
if (AtmIsFlat())
{
if (!AllowCheckStrategies())
{
return;
}
_strategiesController.CheckStrategies();
if (_orderFlowBotState.ValidStrategyDirection == Direction.Long)
{
_atmStrategyId = GetAtmStrategyUniqueId();
_lastTradeBarNumber = _dataBars.Bar.BarNumber;
_entryName = _orderFlowBotState.ValidStrategy.ToString();
string atmTemplateName = ChartControl.OwnerChart.ChartTrader.AtmStrategy.Template;
AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day, _atmStrategyId, atmTemplateName, _atmStrategyId, (atmCallbackErrorCode, atmCallbackId) =>
{
if (atmCallbackId == _atmStrategyId)
{
if (atmCallbackErrorCode == ErrorCode.NoError)
{
_isAtmStrategyCreated = true;
}
}
});
}
if (_orderFlowBotState.ValidStrategyDirection == Direction.Short)
{
_atmStrategyId = GetAtmStrategyUniqueId();
_lastTradeBarNumber = _dataBars.Bar.BarNumber;
_entryName = _orderFlowBotState.ValidStrategy.ToString();
string atmTemplateName = ChartControl.OwnerChart.ChartTrader.AtmStrategy.Template;
AtmStrategyCreate(OrderAction.Sell, OrderType.Market, 0, 0, TimeInForce.Day, _atmStrategyId, atmTemplateName, _atmStrategyId, (atmCallbackErrorCode, atmCallbackId) =>
{
if (atmCallbackId == _atmStrategyId)
{
if (atmCallbackErrorCode == ErrorCode.NoError)
{
_isAtmStrategyCreated = true;
}
}
});
}
}
}
private bool AtmIsFlat()
{
if (_atmStrategyId == null)
{
return true;
}
return GetAtmStrategyMarketPosition(_atmStrategyId) == MarketPosition.Flat;
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Another GetAtmStrategyMarketPosition ATM strategy ID does not exist error
Collapse
X
-
Another GetAtmStrategyMarketPosition ATM strategy ID does not exist error
Is there a way to suppress it yet? I check it before calling the method.
Code:Tags: None
-
Hello WaleeTheRobot,
Thank you for your post.
This error message is expected if the method is being called when there is no atmStrategyId that exists, or if you are calling the method and the atmStrategyId has changed in your script or is no longer active.
I recommend printing out the atmStrategyID after calling AtmStrategyCreate() method to see what the atmStrategyId being used is. A print could also be added before calling GetAtmStrategyMarketPosition() to see if you are accessing the same atmStrategyId value that was supplied to AtmStrategyCreate().
I also recommend reviewing the SampleAtmStrategy strategy that comes default with NinjaTrader to see how it uses the GetAtmStrategyMarketPosition() method.
Currently, there are no ways to suppress this error message that I am aware of.
I look forward to being of further assistance.
-
I can see that the id is the same and created before calling the method. So it would create it, but still fail the function. It eventually is able to find it later on though.
Code:***** ES - 2 - 2.5 ***** 151456 | Enter Long | RangeRebound ********** ATM Strategy Created ********** c86e5f89c19d45ada7d1e3e476bfe3cf ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf 'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'c86e5f89c19d45ada7d1e3e476bfe3cf' does not exist ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf ********** Calling GetAtmStrategyMarketPosition ********** c86e5f89c19d45ada7d1e3e476bfe3cf
Comment
-
I'm not sure how to reduce it. If you want to test it, you can add it in the AddOn and just compile. I think I only see it in real time though. I don't recall seeing it in replay.
Currently, in a dev branch here. https://github.com/WaleeTheRobot/ord...w-bot/tree/dev
The file is at: https://github.com/WaleeTheRobot/ord...rderFlowBot.cs
Comment
-
Hello WaleeTheRobot,
Thank you for your response.
This is most likely a timing issue, since as you've reported it does eventually find the ID. For example, if you create the ATM id and then submit the ATM, the method won't be be able to find it in the same OnBarUpdate() event. It will need to wait for the ATM to start working and the entry order to be filled before it can be used.
Additionally, as you are using OnEachTick, it could be more likely to see these types of errors since the strategy is just polling for information. It has no direct control over an ATM, like it would with strategy-based orders or positions.
Unfortunately, there is currently no way to suppress the message to stop it from appearing before the ATM is ready.
I suggest possibly re-reviewing the SampleATMStrategy strategy script found in the platform, to assure your logic is formatted in the same way to make sure your code is working correctly for ATM strategies.
Please let us know if you have any further questions.
- Likes 1
Comment
-
Thanks for the pointer. I fixed the issue, by adding the check to make sure that the ATM strategy is actually created too.
Code:private bool AtmIsFlat() { if (_atmStrategyId == null || !_isAtmStrategyCreated) { return true; } return GetAtmStrategyMarketPosition(_atmStrategyId) == MarketPosition.Flat; }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
56 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
133 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
73 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment