Is this expected? Is there a way to avoid receiving this error when I run OnEachTick? My suspicion is that a tick occurs and updates the indicator before the order can be initialized in the system.
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
'GetAtmStrategyUnrealizedProfitLoss' method error: ATM strategy ID does not exist
Collapse
X
-
'GetAtmStrategyUnrealizedProfitLoss' method error: ATM strategy ID does not exist
I used the SampleATMPnL as a base and made it send a limit order instead of a market. When I run OnEachTick, sometimes I get the error 'GetAtmStrategyUnrealizedProfitLoss' OR 'GetAtmStrategyEntryOrderStatus' method error: ATM strategy ID does not exist.
Is this expected? Is there a way to avoid receiving this error when I run OnEachTick? My suspicion is that a tick occurs and updates the indicator before the order can be initialized in the system.Tags: None
-
Hello Jack22,
These warnings are expected if the methods are being called when there is no order id that exists. This can happen if you are calling the methods before an order or also after it has filled and a number of ticks have elapsed. The ATM's are not necessarily like strategy orders which persist constantly in your strategy, these instead have a lifetime and once they are gone you would get this message if the method is still being called.
Currently there are no ways to suppress this message that I am aware of, I could only suggest using the managed or unmanaged approach to avoid that.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
-
Hello Forum,
I also face an issue with GetAtmStrategyEntryOrderStatus ... I'm using the exact code to create an order based on the system provided template:
isAtmStrategyCreated = false; // reset atm strategy created check to false
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(OrderAction.Sell, OrderType.StopLimit, Low[0]-3*TickSize, Low[0]-2*TickSize, TimeInForce.Day, orderId, atmTemplate, atmStrategyId, (atmCallbackErrorCode, atmCallBackId)
=> {
//check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId){
isAtmStrategyCreated = true;
}
});
if ( isAtmStrategyCreated == true && orderId.Length > 0 ){
status = GetAtmStrategyEntryOrderStatus(orderId);
// Alert("StrategyOrder", Priority.High, "StrategyOrder submitted" + " Chart Period: " + BarsPeriod.Value.ToString() + " " + BarsPeriod.BarsPeriodType.ToString(), NinjaTrader.Core.Globals.InstallDir+...s\Aler t4.wav", 10, Brushes.Black, Brushes.Blue);
Print("OrderId: " + orderId + " Status: " + status[2]);
}
Here's is the NinjaScript Output after the order AtmStrategyCreate() got triggered:
'GetAtmStrategyEntryOrderStatus' method error: Order ID 'bac1e9602fff474b8317ec94daf4ded1' does not exist
The order does actually get submitted and appears in the system, so why does the system report, that the Order ID does not exist?
My Calculate is set to "On bar close" - does a strategy need to be set to "on each tick"???
Comment
-
Hello abctrader,
Getting the status of an external strategy will rely on that strategies state, from just the syntax I really couldn't say if that was correct or not for the situation.
You can try testing the SampleATMStrategy which also uses this method to see if it reports a similar message in that use case, that could help to confirm if this relates to your logic. It is expected to see this warning when the order no longer exists or if you call this before the order is working/filled. You can try using OnEachTick, that will give you more frequent updates in case the OnBarUpdate is happening outside of where the order can be seen.
If your logic is critical for the state of the orders or targets I would suggest to avoid using the ATM methods and just use the managed or unmanaged approach so you can have complete control over the orders and status of the strategy.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by halgo_boulder, Today, 08:44 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 08:44 AM | ||
Started by drewski1980, Today, 08:24 AM
|
0 responses
3 views
0 likes
|
Last Post
by drewski1980
Today, 08:24 AM
|
||
Started by rdtdale, Yesterday, 01:02 PM
|
2 responses
17 views
0 likes
|
Last Post
by rdtdale
Today, 07:54 AM
|
||
Started by TradeSaber, Today, 07:18 AM
|
0 responses
7 views
0 likes
|
Last Post
by TradeSaber
Today, 07:18 AM
|
||
Started by PaulMohn, Today, 05:00 AM
|
0 responses
10 views
0 likes
|
Last Post
by PaulMohn
Today, 05:00 AM
|
Comment