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
order getting rejected in unmanaged orders submission
Collapse
X
-
order getting rejected in unmanaged orders submission
Hi, I am using unmanaged orders submission like oco for my strategy. many times it shows error that orders are rejected. I am using playback forex data to test the strategy. Please see the screenshot attached for better understanding. I have read articles in this forum regarding this, but I could not find a realistic solution or example to avoid this. Any suggestion will be very helpful and appreciated.Tags: None
-
Hello asmmbillah,
Thanks for your post.
The last error message is advising that the Buy stop or Buy stop limit order that the strategy placed at 1.25807 was at an inappropriate price level relative to where the current price was. These orders must be placed above the current price.
The strategy would need to check before placing these orders that the current price is less than the order price.Paul H.NinjaTrader Customer Service
-
-
Comment
-
Hello asmmbillah,
Thanks for your reply.
In your code you would need to check that your intended order price value is appropriately above or below the actual current price. What check are you currently doing now (post relevant code section) and what calculate mode are you running the strategy on?
Paul H.NinjaTrader Customer Service
Comment
-
Hello asmmbillah,
Thanks for your reply.
What I recommend would be to debug with print statements just prior to your SubmitOrderUnmanaged() methods. You would want to print something like:
Print (Time[0]+" Current price = "Close[0]"+ " Limit Entry price: "+(reEntryUpper + entryOffsetConversion.Tostring())+ " StopLimit price: "+reEntryUpper - entryOffsetConversion.TosTring());
This should get you prints to your output window when you are submitting orders and when you have the error you can check to see what value was in error.
In both your order methods show you are using SellShort, is that what you really mean for both sets?Paul H.NinjaTrader Customer Service
Comment
-
Thanks for your suggestion, I have added and tested that and found the below:
16/07/2019 22:30:00 Current price = 1.24127 Limit Entry price: 1.24120.0005 StopLimit price: 1.2407
where StopLimit is lower the the current price, but still shows the same error. Any advise?
I have sent you the code for the short side only which includes both sets.
Comment
-
Hello asmmbillah,
Thanks for your reply.
It looks like the print statement needs to be adjusted to add the values together before converting to string:
Print (Time[0]+" Current price = "Close[0]"+ " Limit Entry price: "+(reEntryUpper + entryOffsetConversion).Tostring()+ " StopLimit price: "+(reEntryUpper - entryOffsetConversion).ToString());
If I am reading correctly you are submitting a sell limit at 1.24125 while the current price is 1.24127, so keep in mind that you have order transmission time (internet speed) and the actual price may be moving rapidly making your price submitted invalid. As a test, I would suggest that you increase your distance value from the current price and see if that eliminates reduces these errors.
Paul H.NinjaTrader Customer Service
Comment
-
Thanks for your reply.
For some reason, I just tried replacing GetCurrentBid() with Close[0], that solved the error. Can you please tell me what will be the differece between GetCurrentBid() and Close[0] in terms of price?
Comment
-
Hello asmmbillah,
Thanks for your reply.
If you look at a Forex instrument on the super dome, the yellow would be the current price (Close) (last) and the green would be the (GetCurrentAsk()) ask price and you may see them as being the same at times and at other times there being a spread where the ask is higher.Last edited by NinjaTrader_PaulH; 02-25-2020, 08:38 AM. Reason: Corrected GetCurrentBid to GetCurrentAsk and changed references from bid to ask.Paul H.NinjaTrader Customer Service
Comment
-
Thanks for your reply, but still I am not clear. there is bid price which I can get by GetCurrentBid() and ask with GetCurrentAsk(), then what this Close[0] gives me? is it just the Current close of the live bar on the chart?
Comment
-
Hello asmmbillah,
Thanks for your reply.
Sorry for any confusion. I see that in my reply I incorrectly stated that "on the super dome, the yellow would be the current price (Close) and the green would be the (GetCurrentBid()) bid price" I meant to say the GetCurrentAsk() is what is shown. I will edit my previous reply to reflect that correction.
When using the Calculate.OnPriceChange, the Close[0] would be the current (last) price which would be the current close price of the currently forming bar meaning it it the current price of the instrument. In the case of Forex, the last price will be filled at the Bid price. Another way to visualize this would be to add the indicator Price Line and enable (show) the bid and ask line of that indicator. Note that the "last" line is always on top of the "Bid Line" and occasionally on the "ask line".
Paul H.NinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by gbourque, Today, 06:39 AM
|
2 responses
14 views
0 likes
|
Last Post
by gbourque
Today, 07:05 AM
|
||
Started by rexsole, Today, 08:39 AM
|
0 responses
4 views
0 likes
|
Last Post
![]()
by rexsole
Today, 08:39 AM
|
||
Started by trilliantrader, Yesterday, 03:01 PM
|
3 responses
30 views
0 likes
|
Last Post
|
||
Started by cmtjoancolmenero, Yesterday, 03:58 PM
|
4 responses
26 views
0 likes
|
Last Post
|
||
Started by Brevo, Today, 01:45 AM
|
1 response
14 views
0 likes
|
Last Post
|
Comment