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
MultiBroker Strategy Error
Collapse
X
-
MultiBroker Strategy Error
Hi. I have ninjatrader 8.0.23.2 and with multibroker lifetime license. I am trying to use simple MACD ATM strategy on SPY chart and trigger the order for Thinkorswim. But I am getting the below error, could you please guide me on the error. Thanks. Error image attached.
Tags: None
-
Hello victorNT,
Thank you for your post.
To clarify, is this in regards to an ATM strategy where you are manually placing orders? This forum is for discussion of automated strategies using NinjaScript. For future reference, inquiries regarding ATM strategies should be posted in the general Platform Support forum.
That being said, if you are referring to an ATM Strategy, this message would be referring to your broker requiring that Market orders be submitted with a TIF setting of "DAY". There are TIF settings both in the ATM setup and in the order entry window you are using to submit your entry order. If you set the TIF to DAY in the Chart Trader TIF setting, do you still receive the error?
Thanks in advance; I look forward to assisting you further.Kate W.NinjaTrader Customer Service
-
Thanks for the reply. I have changed it to DAY instead of GTC in the Strategy Window. It works, but then once the Buy order is submitted the Strategy Enable option gets unchecked, and the Exit_Buy / Sell order is not submitted.
So that makes the automated strategy useless.
Comment
-
Originally posted by NinjaTrader_Kate View PostHello victorNT,
Thank you for your reply.
Is both the setting in the setup for the ATM strategy and the Chart Trader set to DAY?
Thanks in advance; I look forward to assisting you further.
Comment
-
-
Originally posted by NinjaTrader_Kate View PostHello victorNT,
Thank you for your reply.
Would you be able to supply a screenshot of the current setup you're using for the ATM strategy?
Thanks in advance; I look forward to assisting you further.
Here is the screenshot attached. The strategy is currently live with simple macd crossover. I could report to you in a few minutes the results for the attached settings. Thanks.
Comment
-
Hello victorNT,
Thank you for your reply.
From your screenshot it appears you are working with a NinjaScript Strategy, not an ATM Strategy. ATM Strategies are strategies used with manual trading and are not the same as an automated NinjaScript strategy (although it is possible to use an ATM template within a NInjaScript strategy, that does not appear to apply here - since we can see the prior historically calculated trades on the chart with the strategy applied, it would have to be using Strategy methods to submit orders.
When enabling a strategy on a TD Ameritrade account, TimeInForce must be set to DAY if market orders are used. Otherwise, the user may see order rejections like “MARKET and MARKET_ON_CLOSE must have a duration of DAY”, as you were previously seeing.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Kate View PostHello victorNT,
Thank you for your reply.
From your screenshot it appears you are working with a NinjaScript Strategy, not an ATM Strategy. ATM Strategies are strategies used with manual trading and are not the same as an automated NinjaScript strategy (although it is possible to use an ATM template within a NInjaScript strategy, that does not appear to apply here - since we can see the prior historically calculated trades on the chart with the strategy applied, it would have to be using Strategy methods to submit orders.
When enabling a strategy on a TD Ameritrade account, TimeInForce must be set to DAY if market orders are used. Otherwise, the user may see order rejections like “MARKET and MARKET_ON_CLOSE must have a duration of DAY”, as you were previously seeing.
Please let us know if we may be of further assistance to you.
But there are a few missed orders. As per the image attached , the blue circle should have been 2 Sell orders. (one is the exit_buy and the 2nd should have been opening a sell position). In my TDA account, it shows only 1 sell order executed and 2 sell orders cancelled? Don't understand why is this happening?
Comment
-
Hello victorNT,
Thank you for your reply.
The first thing I would recommend would be to turn on the Order Trace function:
Strategy Builder > Default Properties > More Properties > Trace Orders, or:
if (State == State.SetDefaults)
{
TraceOrders = true;
}
Once you then recompile the strategy, you can open a new NinjaScript Output window under New > NinjaScript Output. This will print a log of any orders submitted by the strategy during while it's running, along with any ignored orders. You can then look through and see what may be occurring.
Here is a link to our help guide that goes into more detail on tracing orders:
https://ninjatrader.com/support/help...aceorders2.htm
Trace orders alone may not give you the full picture of whether or not a trade should have been entered on a given bar, so adding prints to your strategy that will show in the NinjaScript Output window, with information on what the variables you're using for your conditions are on a particular bar, can be helpful.
This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.
https://ninjatrader.com/support/foru...ns-not-working
If you run into issues like we saw here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess what is different between the two.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
-
Hi,
Could you please help me with what would be best way to code this strategy. The strategy is based on SPX500 macd crossover with 200 range chart. But as I can't buy SPX500, I am buying the SPY based on SPX500 macd crossover strategy.
The SPY is set to minute chart. I think I will have to set the bars update property right, as the aggregation period for both the charts is different. Could you please check the code below and guide me to correct it. I have read the documentation and accordingly tried to write the code, but some orders based on SPX500 MACD crossover are not getting triggered on the SPY minute chart. Appreciate it and thanks.
Comment
-
Hello victorNT,
Thank you for your reply.
The only obvious issue I see in your code is calling ExitLong() and EnterShort() on the same pass through OnBarUpdate. EnterShort() will automatically submit an order to exit an opposite position, so if you also call ExitLong, what occurs is that the Exit long will submit a short Market order to exit the long position. Since we're still on the same pass through OnBarUpdate, EnterShort doesn't see the position as closed yet, and submits another short order to exit the long position, as well as yet another short order to bring you to what it thinks is a short 1 position. Since we've had 3 orders when we should have 2, you'd end up in a 2 short position when you intended to be in a 1 short position.
That being said, if you're concerned it's not entering orders when you think it should, the first thing to do would be to turn on the Trace Orders function as previously mentioned:
The first thing I would recommend would be to turn on the Order Trace function:
Strategy Builder > Default Properties > More Properties > Trace Orders, or:
if (State == State.SetDefaults)
{
TraceOrders = true;
}
Once you then recompile the strategy, you can open a new NinjaScript Output window under New > NinjaScript Output. This will print a log of any orders submitted by the strategy during while it's running, along with any ignored orders. You can then look through and see what may be occurring.
Here is a link to our help guide that goes into more detail on tracing orders:
https://ninjatrader.com/support/help...aceorders2.htm
Trace orders alone may not give you the full picture of whether or not a trade should have been entered on a given bar, so adding prints to your strategy that will show in the NinjaScript Output window, with information on what the variables you're using for your conditions are on a particular bar, can be helpful.
This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.
https://ninjatrader.com/support/foru...ns-not-working
If you run into issues like we saw here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess what is different between the two.Kate W.NinjaTrader Customer Service
Comment
-
Hi. For simplicity I have removed the sell condition and the strategy it is only long and exit_long based on MACD crossover ZeroLine on the SP500 (200 Range Chart). As per the attached image, could you please explain me why it missed today's open signal as marked in blue.
I am also attaching a screenshot of the Strategy code which is now long only. For the Trace orders, I will do it in weekend when I have time, but in the meantime if you could help me pinpoint what I should do in the Strategy code, it would save me a lot of time. I guess it has something to do with the bars. Appreciate it. Thanks.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by aussugardefender, Today, 01:07 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
238 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
383 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
||
Started by oviejo, Today, 12:28 AM
|
0 responses
1 view
0 likes
|
Last Post
by oviejo
Today, 12:28 AM
|
||
Started by pechtri, 06-22-2023, 02:31 AM
|
10 responses
125 views
0 likes
|
Last Post Today, 12:03 AM |
Comment