Currently I have the same strategy running both on a Live account and a Sim101 account. The strategy places a TP and SL when a particular order is filled, but sometimes fails to do this on the Live account while it executes perfectly on the Sim101 account. Is there any way to resolve this problem?
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
Live Strategy Does Not Execute The Same As Sim101
Collapse
X
-
Live Strategy Does Not Execute The Same As Sim101
Good morning Ninjatrader staff,
Currently I have the same strategy running both on a Live account and a Sim101 account. The strategy places a TP and SL when a particular order is filled, but sometimes fails to do this on the Live account while it executes perfectly on the Sim101 account. Is there any way to resolve this problem?Tags: None
-
This is the part of the code that fails to trigger.
if (S1 != null && S1 == execution.Order)
{
if (execution.Order.OrderState == OrderState.Filled)
{
TP = ExitShortMIT(0, true, 1, KyoriBands(TwentyFive, Fifty, SeventyFive).Low2[0], "TP", "S1");
SL = ExitShortStopMarket(0, true, 1, Close[1] + 1 * TickSize, "SL", "S1");
}
}
-
Hi GLFX005, thanks for your question.
From the code sample it looks like you are not checking for partially filled orders, which can happen on live accounts. You can also better simulate partially filled orders on the Sim101 account by enabling "Enforce Partial Fills" under Tools>Options. We have an example here that uses OnOrderUpdate and OnExecutionUpdate to submit protective orders and it even handles partially filled orders. Please replicate this in your code and let me know if you are still seeing this issue.
Kind regards,
-ChrisLChris L.NinjaTrader Customer Service
Comment
-
Hello Chris,
I don't see how this could cause any issues since I am using only 1 contract to trade with, meaning that partial fills can't occur. The first trade happening after every restart of the strategy always comes back in the Filled order state but fails to trigger the code I have provided above in blue. A possible cause could be that I am using the "if Historical = return;" logic or that there's an issue with S1 remaining null even if the order has been Accepted and Filled. The strange thing is that it only happens Live and never on Sim101, so maybe it's a broker issue? I am connected to Dorman through Ninjatrader Brokerage.
Comment
-
Hi GLFX005, thank you for clarifying.
There might be an error message related to the stop order. Please turn on TraceOrders in State.SetDefaults "TraceOrders = true;" and this will print out information about all orders made by the strategy. If the code is actually calling your stop loss order and its not being submitted there should be an error listed in the trace orders.
I look forward to hearing from you.Chris L.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by f.saeidi, Today, 12:14 PM
|
7 responses
15 views
0 likes
|
Last Post
by f.saeidi
Today, 01:32 PM
|
||
Started by Russ Moreland, Today, 12:54 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:01 PM | ||
Started by philmg, Today, 12:55 PM
|
1 response
7 views
0 likes
|
Last Post Today, 01:00 PM | ||
Started by TradeForge, 04-19-2024, 02:09 AM
|
2 responses
32 views
0 likes
|
Last Post
by TradeForge
Today, 12:32 PM
|
||
Started by aprilfool, 12-03-2022, 03:01 PM
|
3 responses
329 views
0 likes
|
Last Post Today, 12:31 PM |
Comment